Skip to content

Commit 052dae7

Browse files
committed
Centralize default global analyzer config.
1 parent 681ad44 commit 052dae7

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.zou.default.globalconfig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# To import following rules:
2+
#
3+
# - for all bundle projects, modify 'bundle/Directory.Build.Props'
4+
#
5+
# <Import Project="zou\Directory.Build.Default.props" />
6+
# <Import Project="zou\GlobalAnalyserConfig.Default.props" Condition="'$(ZouAnalyzerConfigFile)' == ''" />
7+
#
8+
# - for all module projects, modify 'module/Directory.Build.Props'
9+
#
10+
# <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
11+
# <Import Project="$(ZouDir)GlobalAnalyserConfig.Default.props" Condition="'$(ZouAnalyzerConfigFile)' == ''" />
12+
#
13+
# See also:
14+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig
15+
16+
# Configure precedence - https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#precedence
17+
# can be overriden in bundle -> set global_level = 100 (default)
18+
# can be overriden in module -> set global_level = 200
19+
global_level = 0
20+
21+
# see https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#format
22+
is_global = true
23+
24+
# IDE0007: Use implicit type
25+
dotnet_diagnostic.IDE0007.severity = suggestion
26+
27+
# IDE0008: Use explicit type
28+
dotnet_diagnostic.IDE0008.severity = none
29+
30+
# IDE0011: Add braces
31+
dotnet_diagnostic.IDE0011.severity = suggestion
32+
33+
# IDE0022: Use block body for method
34+
dotnet_diagnostic.IDE0022.severity = suggestion
35+
36+
# IDE0039: Use local function
37+
dotnet_diagnostic.IDE0039.severity = suggestion
38+
39+
# IDE0045: Convert to conditional expression
40+
dotnet_diagnostic.IDE0045.severity = suggestion
41+
42+
# IDE0046: Convert to conditional expression
43+
dotnet_diagnostic.IDE0046.severity = suggestion
44+
45+
# IDE0051: Remove unused private members
46+
dotnet_diagnostic.IDE0051.severity = suggestion
47+
48+
# IDE0055: Fix formatting
49+
dotnet_diagnostic.IDE0055.severity = none
50+
51+
# IDE0061: Use block body for local function
52+
dotnet_diagnostic.IDE0061.severity = none
53+
54+
# IDE0130: Namespace does not match folder structure
55+
dotnet_diagnostic.IDE0130.severity = none
56+
57+
# IDE0200: Remove unnecessary lambda expression
58+
dotnet_diagnostic.IDE0200.severity = suggestion

GlobalAnalyzerConfig.Default.props

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--
2+
To enable Default GlobalAnalyzerConfig
3+
4+
- for all bundle projects, modify 'bundle/Directory.Build.Props'
5+
6+
<Import Project="zou\Directory.Build.Default.props" />
7+
<Import Project="zou\GlobalAnalyzerConfig.Default.props" Condition="'$(ZouAnalyzerConfigFile)' == ''" />
8+
9+
- for all module projects, modify 'module/Directory.Build.Props'
10+
11+
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
12+
<Import Project="$(ZouDir)GlobalAnalyzerConfig.Default.props" Condition="'$(ZouAnalyzerConfigFile)' == ''" />
13+
14+
See also:
15+
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig
16+
-->
17+
18+
<Project InitialTargets="TraceGlobalAnalyzerConfigFiles">
19+
20+
<PropertyGroup>
21+
<ZouAnalyzerConfigFile>$(MSBuildThisFileDirectory).zou.default.globalconfig</ZouAnalyzerConfigFile>
22+
</PropertyGroup>
23+
<ItemGroup>
24+
<!-- avoid duplicates with the 'Exclude' trick -->
25+
<GlobalAnalyzerConfigFiles Include="$(ZouAnalyzerConfigFile)" Exclude="@(GlobalAnalyzerConfigFiles)" />
26+
</ItemGroup>
27+
28+
<Target Name="TraceGlobalAnalyzerConfigFiles"
29+
Condition="'$(ZouTrace)' == 'true' Or '$(MSBuildProjectFile)' == '$(MSBuildThisFile)'">
30+
<Message Importance="high" Text="### [$(MSBuildProjectFile)] -&gt; GlobalAnalyzerConfigFile = %(GlobalAnalyzerConfigFiles.Identity)" Condition="Exists('%(GlobalAnalyzerConfigFiles.Identity)')" />
31+
</Target>
32+
33+
</Project>

0 commit comments

Comments
 (0)