How can we help you today? How can we help you today?
Clive Tong
Unless CurrentOrganization is defined in the Organization class, I don't think you'd expect it to turn up. The query is finding places where a method defined in MyProduct.Library.Organization is being used. So, for example, in the following, namespace ConsoleApplication12 { public class A { public virtual void Test() { } } class Program { static void Main() { A a = new A(); a.Test(); } } } I can use the (slightly) modified query from a in assemblyManager.Assemblies.Cast<IAssembly>() from m in a.Modules.Cast<IModule>() from t in m.Types.Cast<ITypeDeclaration>() from mt in t.Methods.Cast<IMethodDeclaration>() where mt.Body is IMethodBody from i in ((IMethodBody) mt.Body).Instructions.OfType<IInstruction>() where i.Value != null let memberReference = i.Value as IMemberReference where memberReference != null let referencedType = memberReference.DeclaringType as ITypeReference where referencedType != null && referencedType.Name == "A" && referencedType.Namespace == "ConsoleApplication12" select "Method " + mt.Name + " in " + t.Name + " uses " + memberReference.Name; to get the results Method Main in Program uses .ctor Method Main in Program uses Test and that's because the IL has the form .method private hidebysig static void Main() cil managed { .entrypoint .maxstack 1 .locals init ( [0] class ConsoleApplication12.A a) L_0000: nop L_0001: newobj instance void ConsoleApplication12.A::.ctor() L_0006: stloc.0 L_0007: ldloc.0 L_0008: callvirt instance void ConsoleApplication12.A::Test() L_000d: nop L_000e: ret } The memberReference in the let part of the query is being bound to the two instance lines in the above. If you want to look at the return type of a method, you'd need to use IMethodReference (instead of IMemberReference), then convert that into a IMethodDeclaration (using Resolve()) to get the ReturnType. So, as a quick example, if I add the following method to my example class B { public static A Test2() { return new A(); } } and change the Main method to class Program { static void Main() { A x = B.Test2(); } } I can find things that call a method that returns an A using a query of the form from a in assemblyManager.Assemblies.Cast<IAssembly>() from m in a.Modules.Cast<IModule>() from t in m.Types.Cast<ITypeDeclaration>() from mt in t.Methods.Cast<IMethodDeclaration>() where mt.Body is IMethodBody from i in ((IMethodBody) mt.Body).Instructions.OfType<IInstruction>() where i.Value != null let methodReference = i.Value as IMethodReference where methodReference != null let methodDeclaration = methodReference.Resolve() where methodDeclaration != null let returnType = methodDeclaration.ReturnType.Type as ITypeReference where returnType.Name == "A" && returnType.Namespace == "ConsoleApplication12" select "Method " + mt.Name + " in " + t.Name + " uses " + methodReference.Name; which returns Method Main in Program uses Test2 You'd need to do the same for IPropertyReference to trap properties in the same way. / comments
Unless CurrentOrganization is defined in the Organization class, I don't think you'd expect it to turn up. The query is finding places where a method defined in MyProduct.Library.Organization is be...
0 votes
You can use File/Open to navigate to an assembly, but if the assembly is in the GAC then the easiest thing to do is File/Open Cache and then use the filter to find system.web.mvc and then double click it to load it. / comments
You can use File/Open to navigate to an assembly, but if the assembly is in the GAC then the easiest thing to do is File/Open Cache and then use the filter to find system.web.mvc and then double cl...
0 votes
You are running into bugs in the decompiler. Do you know the original language for the assembly that you are decompiling? If it wasn't C#, then the decompiler may have difficulty translating some instruction sequences into C#. / comments
You are running into bugs in the decompiler. Do you know the original language for the assembly that you are decompiling? If it wasn't C#, then the decompiler may have difficulty translating some i...
0 votes
I think they'll been around since the 3.0 days. The following post discusses how they are used for multi-targetting: http://blogs.msdn.com/b/christy/archive ... blies.aspx / comments
I think they'll been around since the 3.0 days. The following post discusses how they are used for multi-targetting: http://blogs.msdn.com/b/christy/archive ... blies.aspx
0 votes
You are probably looking at one of the Reference Assemblies which just contain the metadata and not the IL. If I use File/Open Cache to go to a non-reference assembly, you should see the code. / comments
You are probably looking at one of the Reference Assemblies which just contain the metadata and not the IL. If I use File/Open Cache to go to a non-reference assembly, you should see the code.
0 votes