Initial ruleset (#1)

The initial ruleset is copied from the original repository in Azure DevOps. No configuration or rules have been altered only the text in the `readme` files is translated into english.

Reviewed-on: #1
Co-authored-by: Sören Schmincke <sschmincke@online.de>
Co-committed-by: Sören Schmincke <sschmincke@online.de>
This commit is contained in:
Sören Schmincke 2026-03-22 13:01:23 +01:00 committed by code.uselessbits.org Instance
commit 8d497b8e0c
Signed by: code.uselessbits.org Instance
SSH key fingerprint: SHA256:l+mT+fqljPcpFACr5ZrHAj5KWhIjUoD9YjofWI82L90
5 changed files with 3404 additions and 2 deletions

3248
.NET/.editorconfig Normal file

File diff suppressed because it is too large Load diff

41
.NET/README.md Normal file
View file

@ -0,0 +1,41 @@
# .NET
These are the configuration files for .NET projects or 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. It will set some global compiler configuration and the static analyzers get imported 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](https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers/8.0.0) |
| Microsoft.VisualStudio.Threading.Analyzers | 17.8.14 | [NuGet](https://www.nuget.org/packages/Microsoft.VisualStudio.Threading.Analyzers/17.8.14) |
| Roslynator.Analyzers | 4.6.2 | [NuGet](https://www.nuget.org/packages/Roslynator.Analyzers/4.6.2) |
| Roslynator.CodeAnalysis.Analyzers | 4.6.2 | [NuGet](https://www.nuget.org/packages/Roslynator.CodeAnalysis.Analyzers/4.6.2) |
| Roslynator.Formatting.Analyzers | 4.6.2 | [NuGet](https://www.nuget.org/packages/Roslynator.Formatting.Analyzers/4.6.2) |
| StyleCop.Analyzers | 1.2.0-beta.556 | [NuGet](https://www.nuget.org/packages/StyleCop.Analyzers/1.2.0-beta.556) |
#### Priority
The analyzers are handled with priority. That means, that a violation of a rule from an analyzer with a higher priority overrides a violation of a lower priority analyzer. In case of conflicting rules from different analyzers, the rule from the analyzer with the lower priority 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`.

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- General compiler configuration. -->
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AnalysisLevel>latest</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
</PropertyGroup>
<PropertyGroup>
<!--
Workaround for changing severity of rules with Location.None - e.g. CA1014
- see https://github.com/dotnet/roslyn/issues/37876#issuecomment-738042719
Needed until those types of rules can be disabled in a Global Analyzer Config
- when https://github.com/dotnet/roslyn/issues/48634 is implemented.
# CA1014: Mark assemblies with CLSCompliantAttribute
-->
<NoWarn>$(NoWarn);CA1014</NoWarn>
</PropertyGroup>
<ItemGroup>
<!--
These two options are necessary for IDE0130 to work:
- see https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0130
# IDE0130: Namespace does not match folder structure
-->
<CompilerVisibleProperty Include="RootNamespace" />
<CompilerVisibleProperty Include="ProjectDir" />
</ItemGroup>
<!-- Include StyleCop Configuration from repository root. -->
<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>
<!-- Include static code analyzers. -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" Version="4.6.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.6.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

35
.NET/stylecop.json Normal file
View file

@ -0,0 +1,35 @@
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"fileNamingConvention": "metadata"
},
"indentation": {
"indentationSize": 4,
"tabSize": 4,
"useTabs": false
},
"layoutRules": {
"allowConsecutiveUsings": false,
"newlineAtEndOfFile": "require"
},
"maintainabilityRules": {
"topLevelTypes": [
"class",
"interface",
"struct",
"enum"
]
},
"namingRules": {
"includeInferredTupleElementNames": true
},
"orderingRules": {
"blankLinesBetweenUsingGroups": "omit",
"usingDirectivesPlacement": "outsideNamespace"
},
"readabilityRules": {
"allowBuiltInTypeAliases": false
}
}
}

View file

@ -1,3 +1,12 @@
# coding-conventions # Coding Conventions
This project hosts the configuration, rules and conventions that must be followed when developing software.
A collection of coding conventions to follow in all projects. You can customize this template locally in your projects, but all changes have to be explained by a comment.
## Structure
Configuration files that are imported into the IDE globally are stored in the root of this repository. There are folders for files that cover specific development environments or frameworks.
| Folder | Description |
|--------|----------------------------------------------|
| .NET | Configuration for .NET projects or solutions |