Skip to content

Package that applies a workaround to get IDE0005 (unnecessary usings) in the CLI build

License

Notifications You must be signed in to change notification settings

shuebner/CheckUnnecessaryUsings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SvSoft.MSBuild.CheckUnnecessaryUsings

Enable the compiler check for unnecessary usings (IDE0005) in CLI builds just by including this package.

<PackageReference Include="SvSoft.MSBuild.CheckUnnecessaryUsings" Version="1.0.0" PrivateAssets="all" />

The package will enforce style checking in the build by setting EnforceCodeStyleInBuild. (You may thus get additional non-IDE0005 style-related warnings, depending on your style settings.) It will also set the diagnostic severity of IDE0005 to warning for the consuming project via a global analyzer config file. The severity will be overridden by default by any .globalconfig file or any other global analyzer config file with a global_level greater than 10.

Background

There is a long standing issue in Roslyn that prevents the CLI build from checking for unnecessary usings unless XML doc generation is turned on. Yes, I know, crazy. There is a comparatively simple workaround. But it has some disadvantages:

  • causes an unwanted and unnecessary potentially empty XML doc file to be included in the output folder
  • has to be manually disabled as soon as the project does want real XML doc generation

In contrast, this solution does not leave any unnecessary files in the output folder. It will also only trigger when GenerateDocumentationFile is false (default) in the consuming project. As soon as XML doc file generation is enabled by setting it to true, the workaround will no longer trigger and thus not have any unwanted side-effects. In particular, the warnings about missing XML comments (CS1591 and CS1573) will be issued as expected.

About

Package that applies a workaround to get IDE0005 (unnecessary usings) in the CLI build

Resources

License

Stars

Watchers

Forks

Packages

No packages published