JetBrains / resharper-nuget

Plugin for ReSharper to support NuGet references correctly
Apache License 2.0
94 stars 8 forks source link

Support the remove unused references refactoring #3

Open citizenmatt opened 12 years ago

citizenmatt commented 12 years ago

Is this possble?

mwjackson commented 11 years ago

What's the first place to look for this?

citizenmatt commented 11 years ago

There are several entry points. Fire up dotPeek, and look for:

Then it will be a matter of legwork - follow the code to see where it goes, and what it's looking for, and how we can hook into it. If I remember rightly, ReSharper is trying to get all references to types that exist in the known references. If it finds them, they're in use, and can be removed. If it doesn't, then it flags the reference as something that can be removed.

I haven't really looked into how we can get this working yet, but there are lots of things we can do - if ReSharper is looking for references, can we add a reference to nuget assemblies? What would that give us? Or can we hook assembly removal, so at the least, can we call package uninstall when an assembly is removed? Or perhaps we can add a group into the analyse references window that shows what assemblies are nuget packages, so even if ReSharper can't tell us if a package should be removed or not, at least we're showing the user that these are packages. Or something else - ReSharper has LOTS of extensibility points.

Basically, I'm saying I don't know how to do this, but there's always options :smile:

jrnail23 commented 11 years ago

+1

kskrygan commented 11 years ago

You can use ReferencedCodeSearcher solution component. This is the core engine for 'optimize references', 'find dependent code' and some other features. In a couple of words, this engine asynchronously, in multiple threads, searches for references inside the given scope to the given targets.

mitchell-etter commented 9 years ago

+1

asbjornu commented 9 years ago

Not having this makes the "Remove Unused References" pretty useless in any project these days, as almost all projects have at least one NuGet reference and most have a ton. So a big :+1: from me!