Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Last active January 31, 2024 22:43
Show Gist options
  • Save MelbourneDeveloper/dfb17737c1a74641c86641531b51e5eb to your computer and use it in GitHub Desktop.
Save MelbourneDeveloper/dfb17737c1a74641c86641531b51e5eb to your computer and use it in GitHub Desktop.
Directory.Build.props Enable All Errors
[*.{cs,vb}]
dotnet_diagnostic.CA1062.severity = none
# IDE0022: Use block body for method
csharp_style_expression_bodied_methods = true
# IDE0032: Use auto property
dotnet_style_prefer_auto_properties = true
#CSharpier Incompatible Rules
dotnet_diagnostic.SA1009.severity = none
dotnet_diagnostic.SA1111.severity = none
dotnet_diagnostic.SA1633.severity = none
dotnet_diagnostic.SA1502.severity = none
#Don't like these
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1623.severity = none
dotnet_diagnostic.SA1515.severity = none
dotnet_diagnostic.SA1516.severity = none
#Not sure why this is necessary
dotnet_diagnostic.CA1016.severity = none
#What's the recommendation these days?
dotnet_diagnostic.SA1309.severity = none
dotnet_diagnostic.SA1101.severity = none
#Too onerous
dotnet_diagnostic.SA1615.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1611.severity = none
#This is an analyzer bug when using records
dotnet_diagnostic.SA1313.severity = none
#This also seems to be a bug when using array initializers
dotnet_diagnostic.SA1010.severity = none
dotnet_diagnostic.SA1011.severity = none
# IDE0040: Add accessibility modifiers
dotnet_style_require_accessibility_modifiers = never
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<WarningsNotAsErrors></WarningsNotAsErrors>
<Deterministic>true</Deterministic>
<LangVersion>Latest</LangVersion>
<DebugSymbols>true</DebugSymbols>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>true</RunAnalyzers>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"/>
</ItemGroup>
</Project>
@sharwell
Copy link

Can you tell me why this new format exists, and why it's better than editor config

It applies to all files in a build and not just the ones matching the filter (i.e. it works like a proper replacement for .ruleset files). The format is equivalent to .editorconfig aside from section headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment