Home > Net >  how to find items in code coming from a specific package
how to find items in code coming from a specific package

Time:01-12

In Visual Studio 2022 we have the classic search function with which we can find a particular string of text in our solution. I'm wondering if there is a way to lookup all the classes inside a file that are defined in a package that is imported via the using directive.

Say for example i'm using package x.Business in my namespace using x.Business; is there a way to then lookup the classes inside this namespace which are coming from this imported package?

CodePudding user response:

What I think you're asking is... "In any class file in my own solution, I want to be able to identify which types used in it (for parameters, variables, etc) are from a particular assembly that is in a using directive."

I don't know of any tool that does this, but the easiest way to identify usages in your file is to comment out the using directive. Any types, methods, etc that exist in that namespace will turn red showing that they can't be found.

(By the way, now is a good time to learn the proper term for those lines at the top of the class files. They're called "using directives", and they're not importing a whole package necessarily, but rather a particular namespace. Not to be confused with "using statements", which are a statement you can write inside of a method that automatically handles disposing of resources.)

  • Related