I should know this but can't seem to remember.
How do I find out if a type is being used in an assembly (and not just that it exists in the assembly, which is the easy part).
class Dog { }
class Cat { }
class Rat { }
public object GetAnimal()
{
if (today.Is(DayOfWeek.Monday))
{
return new Dog();
}
else
{
return new Cat();
}
}
I want both Cat and Dog to show up as they can potentially be loaded at some time, but since Rat isn't being used, I don't want it to show up in my results.
Click the three dots at the top right of the browser, then hover over More tools, then select Task Manager. You can fast-track this process by pressing SHIFT+ESC on Windows. You should see a few processes running, the tabs you have open, and any extensions you've installed.
To release memory, assign the global variable to null . window. users = null; I want to make this article as easy to understand as possible.
So to be clear the question is how do you find out if a class is used somewhere within the current project, which is a project that you have the source code for?
Assuming you are using Visual Studio, the easiest thing to do would be to load that project (not the entire multi-project solution) and then right-click on the class name and select "Find All References" (Shift + F12). The results will show each spot within the project that the class is used. In your case if the results are > 1 then the class is used somewhere within the project.
In your example the Rat class would only have one entry in the search results. The Cat and Dog classes would have two results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With