Find all DLL links in a project

In Visual Studio 2010 (or 2012), there is a way to find all the links in the code that indicate any class / method defined in the referenced DLL.

I currently have two processes that I use (depending on the situation):

  • The first of these involves simply removing the dll link from the project and then notifying all build errors.
  • Another way is to open the link in the Object Browser and then expand the namespaces on it, and for each namespace I do a manual search, but this does not always help to find all the links, and because the legacy code has the same namespaces spanning multiple assemblies contain a lot of noise for filtering.

None of these are truly ideal; is there an easier way to do this? possibly through the VS extension.

+7
source share
3 answers

You can find this if you install Resharper:

Expand References and select Find code Dependent on Module

enter image description here

Then the results are displayed as follows:

enter image description here

+6
source

You do not have Resharper, but you have Sublime Text?

In Sublime Text, select "open folder" and select the folder containing the solution. Then select the menu item Find β†’ Find in files ...

In the "Where:" field, enter:

 *.scsproj 

Then in the "Find:" field, find the line

 Include="[full namespaced name of library]" 

eg:

 Include="System.Xml.Linq" 

will find all projects that reference the System.Xml.Linq dll in the solution.

+3
source

Don't have an extension?

Just write a piece of code ... easier ... I find it very easy to edit code through a project file ..

  private static List<string> FindAllRefrences(ref int ctr, string dir, string projectToSearch) { List<string> refs = new List<string>(); foreach (var projFile in Directory.GetFiles(dir, "*.csproj", SearchOption.AllDirectories)) { if (projFile.IndexOf(projectToSearch, StringComparison.OrdinalIgnoreCase) >= 0) continue; //var t = false; var lines = File.ReadAllLines(projFile); foreach (var line in lines) { if (line.IndexOf(projectToSearch, StringComparison.OrdinalIgnoreCase) >= 0) { ctr++; refs.Add(projFile); break; } } } return refs; } 
0
source

All Articles