Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.31 KB

File metadata and controls

31 lines (25 loc) · 1.31 KB

C# Toolkit Modern.CSharp.Templates - Editorconfig

Complete settings for C# 14 code formatting, style, naming style and analysis. Promotes conciseness, readability and leveraging the latest language features. (can also be used with C# 10 - 13)

Noteworthy: the naming styles do not allow an underscore prefix for private fields.

Usage:

  1. On the command line, ensure that the template is installed:

    dotnet new install Modern.CSharp.Templates
    
  2. in the folder where you want to add the editorconfig, type:

    dotnet new mcs-editorconfig
    

It is recommended to include below settings in all .csproj files that are in or below the folder where you create the .editorconfig file:

  <PropertyGroup>
    <Nullable>enable</Nullable>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <AnalysisLevel>preview-All</AnalysisLevel>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
  </PropertyGroup>

Note that for .NET 8 the above AnalysisLevel setting is necessary for command-line builds to respect the severity settings in this .editorconfig. In .NET 9+ these are always respected.

The rationale for non-default settings is documented in the .editorconfig file itself