Hello,
For .NET Core or .NET Standard projects this is not supported at project level.
See the Microsoft documentation, follow the steps in the first note.
Edit See the following.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have to do code analysis for my application with custom ruleset.
Is there any way to add custom ruleset in Visual Studio 2019.
In visual studio 2019, there is no option to add ruleset. Please help me on this.
Regards,
Prabs
Hello,
For .NET Core or .NET Standard projects this is not supported at project level.
See the Microsoft documentation, follow the steps in the first note.
Edit See the following.
Yes you can have custom rules. It is fully documented here. Note that it does not work like it did for the FxCop (pre Roslyn) analyzers. It is not integrated into the project system.
The general preference is to put your custom rules (or exclusions) in your .editorconfig associated with the project or solution you want it applied to. Converting from a ruleset to editorconfig file is documented in the earlier link. If you really want to continue using a ruleset file then you can do so. For NF projects it works correctly. For .NET Core/Standard/5 projects you have to modify the project file. Again, refer to the docs.
If you need to suppress certain rules then the same options existed as before. For general suppression use .editorconfig. If you need to suppress for specific lines of code then the preference is using an attribute in the code. If that isn't possible then you can continue to use a per-project suppression file.
Finally note that the preference is to get the analyzers from the SDK for .NET 5+ and from NuGet prior to that.
Hi,
I added the following custom rulesets in the Editor config file.
dotnet_diagnostic.CA1822.severity = error
dotnet_diagnostic.CA1800.severity = error
When i try to run code analyzer, I did not get any errors for above mentioned rulesets.
Could you please help me on this issue?
Regards,
Prabs