Create initial ruleset
This commit is contained in:
parent
db488d94b3
commit
588f5394f7
5 changed files with 3404 additions and 2 deletions
3248
.NET/.editorconfig
Normal file
3248
.NET/.editorconfig
Normal file
File diff suppressed because it is too large
Load diff
41
.NET/README.md
Normal file
41
.NET/README.md
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# .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](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 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"
|
||||||
69
.NET/directory.build.props
Normal file
69
.NET/directory.build.props
Normal 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
35
.NET/stylecop.json
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
README.md
13
README.md
|
|
@ -1,3 +1,12 @@
|
||||||
# coding-conventions
|
# Coding Conventions
|
||||||
|
This project hosts the configuraton, 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 the projects, but all changes have to be explained by a comment.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
Configuration files that are importet into the IDE globally are stored in the root of this repository. There are folders for files that cover a specific development environments or frameworks.
|
||||||
|
|
||||||
|
| Folder | Description |
|
||||||
|
|--------|----------------------------------------------|
|
||||||
|
| .NET | Configuration for .NET projects or solutions |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue