|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Counting the calls INTO my component?MyAssembly.DLL public MyClass { public void Method1() {;} public void Method2() {;} public void Method3() {;} private void DetectCalls() { //See question below } } I want the DetectCalls method to be able to: 1] Load an arbitrary assembly 2] Find all instances of code (in classes, or structs) in that assembly ** that make calls on any of Method1, Method2 or Method3 ** I see how I can load the assembly, and iterate thru all the types in that assembly, but I stumped on the "check to see if any code in those types calls MyClass in MyAssembly". Is this possible? Can someone give me some pointers as to where to start looking? Cheers, Rob
Show quote
"Robert Hooker" <rhooker@newsgroup.nospam> wrote in message ..NET Reflector by Lutz Roeder does exactly that ("Analyzer" menu option), news:%23gWn1q0fGHA.764@TK2MSFTNGP05.phx.gbl... >I have this class, with 3 public methods: > > MyAssembly.DLL > public MyClass > { > public void Method1() {;} > public void Method2() {;} > public void Method3() {;} > > private void DetectCalls() > { > > //See question below > > } > } > > > I want the DetectCalls method to be able to: > 1] Load an arbitrary assembly > 2] Find all instances of code (in classes, or structs) in that assembly > ** that make calls on any of Method1, Method2 or Method3 ** > > I see how I can load the assembly, and iterate thru all the types in that > assembly, but I stumped on the "check to see if any code in those types > calls MyClass in MyAssembly". > > Is this possible? Can someone give me some pointers as to where to start > looking? > Cheers, > Rob and is extensible. Maybe you can do what you need by writing a plugin... Show quote > > > > Thanks for the suggestion - but I need to do this in my own code...
Show quote "Ben Voigt" <rbv@nospam.nospam> wrote in message news:%23taXSm4fGHA.2208@TK2MSFTNGP05.phx.gbl... > "Robert Hooker" <rhooker@newsgroup.nospam> wrote in message > news:%23gWn1q0fGHA.764@TK2MSFTNGP05.phx.gbl... >>I have this class, with 3 public methods: >> >> MyAssembly.DLL >> public MyClass >> { >> public void Method1() {;} >> public void Method2() {;} >> public void Method3() {;} >> >> private void DetectCalls() >> { >> >> //See question below >> >> } >> } >> >> >> I want the DetectCalls method to be able to: >> 1] Load an arbitrary assembly >> 2] Find all instances of code (in classes, or structs) in that assembly >> ** that make calls on any of Method1, Method2 or Method3 ** >> >> I see how I can load the assembly, and iterate thru all the types in that >> assembly, but I stumped on the "check to see if any code in those types >> calls MyClass in MyAssembly". >> >> Is this possible? Can someone give me some pointers as to where to start >> looking? >> Cheers, >> Rob > > .NET Reflector by Lutz Roeder does exactly that ("Analyzer" menu option), > and is extensible. Maybe you can do what you need by writing a plugin... > >> >> >> >> > > You would have to analyze IL in order to do this.
This will not however be 100% reliable as someone could still be calling you through reflections which you would not pick up. The mono project has some open source libraries that make analyzing IL a breeze, but again this is not going to be 100% reliable. Cheers, Greg Show quote "Robert Hooker" <rhooker@newsgroup.nospam> wrote in message news:%23gWn1q0fGHA.764@TK2MSFTNGP05.phx.gbl... >I have this class, with 3 public methods: > > MyAssembly.DLL > public MyClass > { > public void Method1() {;} > public void Method2() {;} > public void Method3() {;} > > private void DetectCalls() > { > > //See question below > > } > } > > > I want the DetectCalls method to be able to: > 1] Load an arbitrary assembly > 2] Find all instances of code (in classes, or structs) in that assembly > ** that make calls on any of Method1, Method2 or Method3 ** > > I see how I can load the assembly, and iterate thru all the types in that > assembly, but I stumped on the "check to see if any code in those types > calls MyClass in MyAssembly". > > Is this possible? Can someone give me some pointers as to where to start > looking? > Cheers, > Rob > > > > |
|||||||||||||||||||||||