Question

  • I have a .NET 4.0 C# Solution with a single .csproj (Library) having several thousand files.
  • I want to extract out a small subset of the functionality from the thousands of files.

e.g. I want to extract the functionality of the MyLibrary.RelevantMethod() method into another library.

The aim is to create a new .csproj with the bare minimum class files needed to achieve this functionality.

  • i have a Program.cs which invokes the functionality and i can navigate through the flow to find all classes involved. Just that there are too many. (still a small subset of all classes)

Solutions tried:

  • the usual brute force of going through the flow from the method (F12) and copying over every class file and associated files needed for it to compile. this is taking a lot of time, but i know that if i keep at it, it'll be done. so that is what i am doing right now.

  • other option was to copy over the whole project and eliminate folders of classes based on instinct/name space references, build to verify and keep at it. this got nasty because a subset of classes in a folder were needed.

  • the vs 2013 code-map graphs became unmanageable in 3 drill downs. sequence diagrams became too complex as well.

  • Call hierarchy seemed to be the most promising showing all the classes involved visually but there is still the manual task of drilling through and copying the classes.

while i manually continue extracting the class one-by-one using the call hierarchy, is there a faster way or a more automated way (semi works as well) to determine all the classes involved in a method call in C#?

if i can get the list, i can do a search on the physical folders nesting the .cs. files (every class has an equivalent .cs file) and just copy them over.

Was it helpful?

Solution

You can find all classes involved in a method call with the Runtime Flow tool (developed by me). From the Runtime Summary window you can also copy these classes to the Clipboard for the selected module or a namespace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top