- defining them directly through the SonarQube web interface using XPath expressions
- or reusing custom ones rules defined in external tools such as FxCop, Gendarme or StyleCop
- Write a piece of XML to reference your custom coding rules. See formats below.
- Go to Settings > Configuration > General Settings > .Net FxCop or .Net Gendarme or C# StyleCop
- Paste this piece of your XML in .NET/C# XXX custom rules
- Click on Save .NET/C# XXX settings
- Restart your SonarQube server
- Activate your custom coding rules in your C# quality profiles
RULE_CLASS: name of the .NET rule class
ASSEMBLY.DLL: name of the dll assembly file containing the rule class
The XML fragment above assumes that the dll is located in the same directory as the standard FxCop assembly rules files.
Note: to help writing write this XML filesfile, "vladonemo" has written a C# program that generates this file based on your custom rules DLL. You can check this out on GitHub, but be aware that this it comes with no guarantee.