Remove unnecessary imports or usings, looking inside 'false' #if blocks

54 Views Asked by At

I was just adding code style and cleanup to my program, looks pretty nice, but my cleanup options include "Remove unnescessary Imports or usings". It turns out that this option removes usings when they appear in greyed-out #if blocks.

I get that it's cutting usings based on what it needs to compile, but isn't there an option so that it only removes them if they aren't references in any #if blocks at all?

I can't find such an option.

Update: It's Visual Studio 2022, Solution is a mix of Web Applications, Console Apps and Class Libraries (including Razor Class Libraries). Not all of them have #if style code, so it's not always a problem.

0

There are 0 best solutions below