coding-conventions/.NET
2026-03-22 12:38:04 +01:00
..
.editorconfig Add initial ruleset 2026-03-22 12:38:04 +01:00
directory.build.props Add initial ruleset 2026-03-22 12:38:04 +01:00
README.md Add initial ruleset 2026-03-22 12:38:04 +01:00
stylecop.json Add initial ruleset 2026-03-22 12:38:04 +01:00

.NET

These are the configuration files for .NET projects and solutions.

You can copy these files into the root of your .NET solution in order to activate the conventions.

directory.build.props

The "directory.build.props" contains important project configuration, that need to be set for all .net projects in your solution. Some global compiler configuration will be set and the static analyzers get importet via NuGet.

.editorconfig

The ".editorconfig" contains configuration for your code editor and the ruleset of the static analyzers. Copy this file into the root of you repository so that it is active for all files and folders.

Analyzers

Name Version NuGet
Microsoft.CodeAnalysis.NetAnalyzers 8.0.0 NuGet
Microsoft.VisualStudio.Threading.Analyzers 17.8.14 NuGet
Roslynator.Analyzers 4.6.2 NuGet
Roslynator.CodeAnalysis.Analyzers 4.6.2 NuGet
Roslynator.Formatting.Analyzers 4.6.2 NuGet
StyleCop.Analyzers 1.2.0-beta.556 NuGet

Priority

The analyzers are handled with priority. That means, that a violation of a rule from a analyzer with a higher priority overrides a violation of a lower priority analyzer. In case of conflicting rules from different analyzers, the rule from analyzer with the lower gets changed or deactivated.

Priority of analyzers:

  1. Microsoft.CodeAnalysis.NetAnalyzers
  2. Microsoft.VisualStudio.Threading.Analyzers
  3. StyleCop.Analyzers
  4. Roslynator.Analyzers
  5. Roslynator.CodeAnalysis.Analyzers
  6. Roslynator.Formatting.Analyzers

stylecop.json

The "stylecop.json" contains the configuration for "StyleCop.Analyzers", that cannot be set via the ".editorconfig". This file must be copied into the root of your repository as it gets imported from there into all .NET projects by the "directory.build.props"