dotnet Code Analysis ignoring certain entries in .editorconfig file

179 Views Asked by At

In a test project I am trying to ignore certain Code Analysis warnings, but I am struggling to understand what I am missing. I have a simple dotnet6.0 console app with the following structure.

Project Structure:

structure

Program.cs:

public class Configuration
{
    public void CatchException()
    {
        try
        {
            Console.WriteLine("Hello, World!");
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }
    }
}

.editorconfig:

root = true

[*]

# Doesn't work    
dotnet_diagnostic.CA1724.severity = none
dotnet_diagnostic.CA1017.severity = none
dotnet_diagnostic.CA1014.severity = none

# Works
dotnet_diagnostic.CA1303.severity = none

CodeAnalysisTesting.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

    <PropertyGroup>
        <AnalysisLevel>6.0-none</AnalysisLevel>
        <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
    </PropertyGroup>

    <ItemGroup>
      <None Include="C:\Users\wjames\source\repos\CodeAnalysisTesting\CodeAnalysisTesting\.editorconfig" />
    </ItemGroup>

</Project>

In visual studio I am getting errors appearing for CA 1724, 1017, 1014 and I am not sure why as CA1303 is ignored successfully. I would understand if all errors were not ignored but why does this one work but the others don't?

VS2022 (17.7.1) dotnet6 sdk (6.0.413)

0

There are 0 best solutions below