manuelroemer / Nullable

A source code only package which allows you to use .NET's nullable attributes in older target frameworks like .NET Standard 2.0 or the "old" .NET Framework.

Home Page:https://www.nuget.org/packages/Nullable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatically exclude attributes from style/code analysis

kzu opened this issue · comments

When installing this package, its item is added to the compilation. If a style rule does not match with the code style in the code file, an analysis error might stop compilation.

To repro, add this to a project's .editorconfig:

# IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0040.severity = error

(this setting will cause a build error if an accessibility modifier is added which is already the default for it, like adding internal to a class).

After installing the package, now you'll get the expected build error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	IDE0040	Accessibility modifiers required	[ProjectName]	[ProjectPath]\obj\3.8.0\Debug\NuGet\3D28A4393902596C02B027108469F4ED40AA07C9\Nullable\1.0.0\Nullable\NullableAttributes.cs	46	Active

I have learned that this can be avoided by simply adding this to the code files somewhere (near the top?): // <auto-generated/>

That eliminates the (spurious) error shown above.

That said, the header all files have as of 1.3.0 does not cause this error either, so, I guess it's safe to close this :)