How can we help you today? How can we help you today?
haleyjason
Here's a query to find where an object is instatianted. If you run this example in the Query Editor, it should find any place the System.IO.Stream type is instantiated in the System.Net namespace. (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 ((ITypeReference)mt.DeclaringType).Namespace == "System.Net" where mt.Body is IMethodBody from i in ((IMethodBody)mt.Body).Instructions.Cast<IInstruction>() where i != null && i.Value != null && i.Value is IMemberReference && ((IMemberReference)i.Value).Name == ".ctor" && ((IMemberReference)i.Value).DeclaringType is ITypeReference && ((ITypeReference)((IMemberReference)i.Value).DeclaringType).Name == "Stream" && ((ITypeReference)((IMemberReference)i.Value).DeclaringType).Namespace == "System.IO" select mt).Distinct() There are 3 things you'll need to change: 1. Namespace filter (in example above = "System.Net") 2. Type name (in example above = "Stream") 3. Type namespace (in example above = "System.IO") Let me know if it doesn't find everything you need - it looks for calls to the class's constructor so it won't look at fields or return types. / comments
Here's a query to find where an object is instatianted. If you run this example in the Query Editor, it should find any place the System.IO.Stream type is instantiated in the System.Net namespace....
0 votes