-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
79 lines (67 loc) · 4.49 KB
/
Copy pathDirectory.Build.props
File metadata and controls
79 lines (67 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<Project>
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsNotAsErrors>NU1701</WarningsNotAsErrors>
<InvariantGlobalization>false</InvariantGlobalization>
<Platforms>AnyCPU;x64</Platforms>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<!-- ==================================================================================
Code quality gate.
The severities of the opt-in rules live in the repo-root .editorconfig, which is
where the flip from `warning` to `error` happens once the existing violations are
cleared. See the "FLIP TO ERROR" banner in that file.
TreatWarningsAsErrors deliberately stays false above: the gate is expressed
per-rule in .editorconfig, not as a blanket "all warnings are fatal", so that an
unrelated new SDK/NuGet warning can never break the build for the wrong reason.
================================================================================== -->
<PropertyGroup Label="Code analysis">
<!-- Defaults to true on net5.0+, but pinned explicitly so it survives an SDK change. -->
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<!-- Track the newest rule set the SDK ships rather than freezing at a version. -->
<AnalysisLevel>latest</AnalysisLevel>
<!-- Deliberately NOT `All`/`Recommended`. Blanket-enabling every CA rule buries the
signal we actually want (complexity + real smells) under hundreds of stylistic
and micro-perf diagnostics. The extra rules we do want are opted into one at a
time, with a rationale, in .editorconfig. -->
<AnalysisMode>Default</AnalysisMode>
<!-- Runs the IDExxxx code-style analyzers as part of the build so the handful of
dead-code rules enabled in .editorconfig (IDE0051/IDE0052/IDE0059) are gated
too, not just visible in the IDE. -->
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!-- `dotnet build /t:Metrics` writes its report next to the project by default, which
would drop four untracked XML files into the working tree. Redirect into obj/,
which .gitignore already covers. Literal "obj\" rather than
$(BaseIntermediateOutputPath): this file is imported before the SDK defines that
property, so it would expand to empty here. The Metrics target Execs with
WorkingDirectory set to the project directory, so a relative path is correct. -->
<MetricsOutputFile>obj\$(MSBuildProjectName).Metrics.xml</MetricsOutputFile>
<!-- NOTE on generated code: there is no MSBuild switch for this - the exclusion is
driven by Roslyn's own generated-code detection (file name *.g.cs / *.designer.cs
/ *AssemblyInfo.cs, an <auto-generated/> header, or a [GeneratedCode] attribute),
which every CA analyzer honours via ConfigureGeneratedCodeAnalysis. That covers
the Avalonia NameGenerator partials, the CommunityToolkit.Mvvm
[ObservableProperty]/[RelayCommand] partials, and everything the SDK emits into
obj/. Verified: a probe build with AnalysisMode=All produced 130 diagnostics in
WhisperNotes.App and not one of them landed in a .g.cs file or under obj/.
The .editorconfig documents the same thing with explicit `generated_code = true`
sections. -->
</PropertyGroup>
<ItemGroup Label="Code analysis">
<!-- CA1501/CA1502/CA1505/CA1506 read their thresholds from an AdditionalFile that
MUST be named exactly `CodeMetricsConfig.txt` (the analyzer matches on file
name). This is the only supported way to change the thresholds - the
`dotnet_code_quality.CA1502.threshold` .editorconfig key does NOT exist and is
silently ignored (verified against Microsoft.CodeAnalysis.NetAnalyzers in SDK
10.0.301). Linked from the repo root so every project shares one threshold set. -->
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CodeMetricsConfig.txt"
Link="CodeMetricsConfig.txt"
Visible="false" />
<!-- Supplies the `Metrics` target: `dotnet build /t:Metrics` -> *.Metrics.xml. -->
<PackageReference Include="Microsoft.CodeAnalysis.Metrics" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>
</Project>