Good practices

Code-style rules

.NET Compiler Platform (Roslyn) Analyzers inspect C# or Visual Basic code for style, quality, maintainability, design, and other issues.

With a EnforceCodeStyleInBuild element set in our .csproj:

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>

    <!-- this! -->
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
  </PropertyGroup>

the code-styles are in the .editorconfig file, which have been autogenerated with:

dotnet new editorconfig

and updating your VS Code settings.json to include:

{
    "omnisharp.enableRoslynAnalyzers": true,
    "omnisharp.enableEditorConfigSupport": true
}

Written this up in more depth here:

ESLint your C# in VS Code with Roslyn Analyzers

References

results matching ""

    No results matching ""