Why is it impossible to remove unused links in C #

Is there any reason why Visual Studio can remove unused links (for projects and assemblies) in C # and C ++ projects, while this is possible from a Visual Basic project ( see here )?

I know that you can do this with other tools like Resharper , I'm just wondering if there is any technical reason for the inability to do this in C # and C ++ projects? Or Microsoft just decided to work like that. This seems to be a pretty useful feature.

+7
source share
3 answers

Note that the compiler automatically removes any unused links from the assembly, so this is redundant at the assembly metadata level. Then it just becomes an IDE / toolkit problem. Would it be impossible? not (although, obviously, to do this, you must save all that are marked as copy-local to ensure its deployment). Therefore, we can assume that this is simply “time to implement vs utility” (compared to other useful things that could be done).

I'm sure you could write an IDE extension if you want, p

+10
source

I found this suggestion about Microsoft Connect. It seems like Microsoft actually thinks this is a good idea, but simply did not have the “time” (read: priority) to implement it. Too bad!

+1
source

This function exists for VB (using the "Unused links" button on the link properties page). But in the case of CSharp, for example, the user can add a link to the assembly so that it can be copied to the output directory. They can use the assembly through reflection instead of compiling against it - in such cases there is no way for VS to detect that such an assembly is “used”. Therefore, the development of such an algorithm is not 100% successful. But the flag is an option that points to the assembly as "unused" (however, the user will still have a choice whether to remove the assembly from the list of links).

Removing unused namespaces might help a bit.

0
source

All Articles