Search code examples
.netmsbuildroslynxunit.netroslyn-code-analysis

Disable Roslyn code analysers on a specific project


I want to add custom assertions to XUnit's Assert, so:

  • I created a "helper" project that references the nuget package xunit.assert.source
  • I add my custom assertions in that project
  • I referenced that helper project from my test project.

That works.

However because that is imported as source, I get hundreds of code analyzer warnings on every build in the cli, and my vscode goes crazy by performing analysis as well.

I tried - unsuccessfully - to disable it for that project by doing this in the csproj:

  <PropertyGroup>
    <EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
  </PropertyGroup>

How can I disable analysis for that specific project?


Solution

    1. You can disable code analysers in .editorconfig: see this question.

    2. An editorconfig in a child folder (setting root = false) will override/extend an .editorconfig in an ancestor folder.

    So add a project specific editorconfig and use that to disable all the analysers you want to.