Stylecopanalyzers: How to not perform static analysis for files in third-party source directories

Created on 10 May 2019  路  7Comments  路  Source: DotNetAnalyzers/StyleCopAnalyzers

Is there any way to make the code in the specified directory not static analysis, because I don't want any changes to the source code of some third-party libraries.

Most helpful comment

I saw this problem(https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2108), but still can't do it so far?

All 7 comments

I saw this problem(https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2108), but still can't do it so far?

Same here.
StyleCop analyzes files from ~/.nuget/packages/ linked by a third-party.
How do I avoid such a strange behavior?

It would similarly nice to exclude generated migration files, for example.

StyleCop analyzes files from ~/.nuget/packages/ linked by a third-party.
How do I avoid such a strange behavior?

The third-party package should be including an // <auto-generated/> comment at the top of each of these files to prevent style analyzers from reporting diagnostics in them.

It would similarly nice to exclude generated migration files, for example.

StyleCop Analyzers already ignores generated files. If the code generator fails to include the required comment at the top of the file, you can either work with the authors of the code generator to include the required comment, or you can override the behavior using a .editorconfig file:

[file-pattern.cs]
generated_code = true

Sometimes third-party packages are not necessarily updated through nuget because they are not published to nuget (They may be managed by directly importing third-party packages into the project or through submodules).

We expect a way to ignore the source code in the inspection project folder.

Is it possible to ignore a method similar to the following:

```.editorconfig
[external/*/.cs]
generated_code = true

// or :
// suppress = external//.cs; submodule//.cs
```

Is it possible to ignore a method similar to the following:

[external/**/*.cs]
generated_code = true

This will work as long as there are no intermediate .editorconfig files that specify root = true (which instructs the processing to ignore files in parent directories).

Thanks, it seems to meet my needs.

Was this page helpful?
0 / 5 - 0 ratings