-
Notifications
You must be signed in to change notification settings - Fork 0
IncludeExcludeFilter
Apply rules to all C# [*.cs] files except selected ones (e.g., [{TestClass1.cs,TestClass2.cs}]).
.editorconfig-main
# StyleCop.Analyzers rules
^biak^ include [*.cs]
^biak^ exclude [{TestFile1.cs,TestFile2.cs}]
dotnet_diagnostic.SA1025.severity = error
dotnet_diagnostic.SA1026.severity = error
dotnet_diagnostic.SA1028.severity = error
^biak^ END include/exclude
# Code analysis (CAxxxx) rules
^biak^ include [*.cs]
^biak^ exclude [{TestFile1.cs,TestFile2.cs}]
dotnet_diagnostic.CA1724.severity = error
dotnet_diagnostic.CA1727.severity = error
dotnet_diagnostic.CA1716.severity = error
^biak^ END include/exclude
...After running the Enable / Disable commands, the .editorconfig file is converted to:
# StyleCop.Analyzers rules
[*.cs]
dotnet_diagnostic.SA1025.severity = error
dotnet_diagnostic.SA1026.severity = error
dotnet_diagnostic.SA1028.severity = error
[{TestFile1.cs,TestFile2.cs}]
dotnet_diagnostic.SA1025.severity = none
dotnet_diagnostic.SA1026.severity = none
dotnet_diagnostic.SA1028.severity = none
# Code analysis (CAxxxx) rules
[*.cs]
dotnet_diagnostic.CA1724.severity = error
dotnet_diagnostic.CA1727.severity = error
dotnet_diagnostic.CA1716.severity = error
[{TestFile1.cs,TestFile2.cs}]
dotnet_diagnostic.CA1724.severity = none
dotnet_diagnostic.CA1727.severity = none
dotnet_diagnostic.CA1716.severity = none
...As you can see, the rules are applied to all files except the specifically excluded ones.
It is also recommended to use the variable functionality together with this feature to avoid duplicating paths.
Warning
Include / Exclude filter works unstable for dotnet format command, so it is recommended to use --exlude filter, for example dotnet format --exlude TestFile1.cs TestFile2.cs
-
It is currently not possible to exclude multiple files using built-in syntax. Only
[!name](for a single file) or{s1,s2,s3}(without!) are supported. -
If done manually, you would need to duplicate rules, which can lead to bugs and maintenance issues.
Hey! If you don't have write access to the wiki, you can change that in the docs/wiki folder.