I am working on ac# project. It reference quite a few packages and there are packages referencing other packages. So a namespace used in the program does not necessarily come from a direct reference. For a specific using statement, is there a way to find out which reference (by reference, I mean the external DLL's/NuGet packages) it is originated from? Thank you.
For example project reference a Nuget Package called Package1. In Package1 we have namespace called Namespace1. Then Package1 references Package2, which have a namespace called Namespace2. In your code you could have
using Namespace2;
But how do you know which assembly or Nuget Package Namespace2 is originated from (in this case Package1)?
I'm not aware of a native means in Visual Studio to do this. However, JetBrains ReSharper can do this. Note that a single namespace import isn't tied to a single assembly. A namespace import (using statement) can easily bring types from several different assemblies into scope.
With ReSharper in hand I simply selected the namespace and pressed F12. You can see that System.Collections.Generic
is defined in four assemblies referenced by this project.
I tried harlam357's answer in visual studio 2019 but it failed (the image bellow).
1.
Then, I did a trick. I turned the reference in to a comment and found the error line which implements a method belong the namespace. Through the method I got the root reference.
2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.