You can find this if you install Resharper:
Expand the References
and choose Find code Dependent on Module
The results then appear like:
题
In Visual Studio 2010 (or 2012) is there a way to locate all references in code that mention any class/method defined in a referenced dll.
Currently I have two processes that I use (depending on the situation):
Object Browser
and then expand to it's namespaces, and for each namespace I do a manual search, but this doesn't always help find all references and because the legacy code has the same namespaces spanning multiple assemblies there's a lot of noise to filter through.Neither of these are really ideal solutions, is there any easier way to do this? perhaps via a VS extension.
解决方案
You can find this if you install Resharper:
Expand the References
and choose Find code Dependent on Module
The results then appear like:
其他提示
Don't have Resharper, but you do have Sublime Text?
in Sublime Text, select 'open folder', and select the folder containing the solution. Then select menu item Find -> Find in Files...
In the 'Where:' field, enter:
*.scsproj
Then in the 'Find:' field, search for the string
Include="[full namespaced name of library]"
for example:
Include="System.Xml.Linq"
will find all projects that reference the System.Xml.Linq dll in the solution.
Don't have any Extension?
Just write a piece of code... easiest... I find it very easy to edit, via code, the 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;
}
Steps for doing this in Visual Studio 2019: