I am attempting to enable code analysis via Nuget for an existing .Net Framework 4.72 Web Application. To be frank, the documentation has me confused as to which packages to install.
I have installed Microsoft.CodeAnalysis.NetAnalyzers via nuget.
The following is in my csproj file:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
...
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
This code is loaded with problems, but I only the following two items are listed:
warning CA2237: Add [Serializable] to ParseException as this type implements ISerializable
warning CA1001: Type 'Repository' owns disposable field(s) '_context' but is not disposable
Are there other packages to load ?
Microsoft.CodeAnalysis.NetAnalyzersNuGet package, you should not add theEnableNETAnalyzersproperty to either your project file or aDirectory.Build.propsfile. When the NuGet package is installed and theEnableNETAnalyzersproperty is set totrue, a build warning is generated. Please see this article for more detail: learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/…