Stylecopanalyzers: Exclude items from analysis

Created on 28 Aug 2016  路  6Comments  路  Source: DotNetAnalyzers/StyleCopAnalyzers

I'm currently taking a dependency on the NuGet package xunit.assert.source in my (.NET core) test project, and I can't figure out how to exclude the source files in that package from analysis.

Is this possible?

question

Most helpful comment

Could we extend the stylecop.json file to have the include/exclude options used by project.json, so you could do something like this (where the files are specified with a globbing pattern, rooted at the project folder):

{
  "settings": {
    "files": {
      "include": String or String[],
      "exclude": String or String[]
    }
  }
}

As with project.json, the exclude patterns would have a higher priority than the include patterns.

I'm happy to submit a pull request if the above sounds reasonable, though I'd like to get the go ahead from a project member first as there are already a few pull requests waiting (though @sharwell is doing a great job getting them closed lately 馃槂)

All 6 comments

I also use source nupkg's and need to exclude the files they bring in.

I got stuck with this and it would be great to have an option to include/exclude folders for this scenario.

The work around I'm using for now is to run a PowerShell script in the precompile section of the project.json file that inserts a <auto-generated /> at the start of the NuGet content files, but it's not a pretty solution.

BTW this issue is not limited to .net core. I think that label should be removed.

Could we extend the stylecop.json file to have the include/exclude options used by project.json, so you could do something like this (where the files are specified with a globbing pattern, rooted at the project folder):

{
  "settings": {
    "files": {
      "include": String or String[],
      "exclude": String or String[]
    }
  }
}

As with project.json, the exclude patterns would have a higher priority than the include patterns.

I'm happy to submit a pull request if the above sounds reasonable, though I'd like to get the go ahead from a project member first as there are already a few pull requests waiting (though @sharwell is doing a great job getting them closed lately 馃槂)

I understand, that analyzers do not cope well with referencing other files. But a mechanism similar to .gitignore would be a really good solution.

Something like ".stylecopignore" that can be placed in any directory.

At this point, this would be a reasonable issue to file on dotnet/roslyn. StyleCop Analyzers 1.1+ does not perform any file exclusions itself, but instead relies on the compiler to decide which files are considered "generated" (its designation for exclusions).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vweijsters picture vweijsters  路  3Comments

jeroenlandheer picture jeroenlandheer  路  3Comments

MartyIX picture MartyIX  路  5Comments

kindermannhubert picture kindermannhubert  路  6Comments

mzhukovs picture mzhukovs  路  4Comments