Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

chore(build): fail the build on any warning

fatDuck0df64aeecff5
diff --git a/.editorconfig b/.editorconfig
index bacdaa9..1f72cb7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,9 +1,14 @@
root = true
# ---------------------------------------------------------------------------
-# Compiler-level opt-ins. AnalysisLevel/AnalysisMode enable the platform and
-# CAxxxx analyzers that the build previously never ran; EnforceCodeStyleInBuild
-# makes IDExxxx style rules fail the build instead of only showing in the IDE.
+# Compiler-level opt-ins. EnforceCodeStyleInBuild runs the IDExxxx style rules
+# inside the build, and TreatWarningsAsErrors (set in both project files) turns
+# every warning into a failure, so the severities below decide what fails.
+#
+# AnalysisMode=All is deliberately not set: on this tree it reported about 7,000
+# warnings, led by CA1515 (1,670, make types internal), CA1848 (1,464, use
+# LoggerMessage source generation) and CA1707 (1,022, no underscores in test
+# names). Each of those contradicts a choice this codebase makes on purpose.
# ---------------------------------------------------------------------------
[*.{cs,csx}]
charset = utf-8
@@ -61,8 +66,6 @@ dotnet_diagnostic.CA1510.severity = suggestion
dotnet_diagnostic.CA1873.severity = suggestion
# Avoid the culture-sensitive overloads of string.Format / int.Parse.
dotnet_diagnostic.CA1305.severity = suggestion
-# Prefer a TimeProvider over DateTime.Now / UtcNow.
-dotnet_diagnostic.CA1305.severity = suggestion
# CA1416 (platform compatibility) is intentionally silent: the app targets a single
# Windows TFM, so every P/Invoke and registry call is known-good.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b2503ed..b02a096 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -33,3 +33,8 @@ jobs:
- name: Test
run: dotnet test optimizerDuck.Test/optimizerDuck.Test.csproj --configuration Release --no-build --logger "console;verbosity=detailed" --blame-hang --blame-hang-timeout 30s
+
+ - name: Format check
+ run: |
+ dotnet tool install --global csharpier --version 1.3.0
+ csharpier check .
diff --git a/optimizerDuck.Test/optimizerDuck.Test.csproj b/optimizerDuck.Test/optimizerDuck.Test.csproj
index 69b6497..7b2d165 100644
--- a/optimizerDuck.Test/optimizerDuck.Test.csproj
+++ b/optimizerDuck.Test/optimizerDuck.Test.csproj
@@ -5,6 +5,9 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
+ <!-- The gate: a warning fails the build, and the promoted style rules run inside it. -->
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
<ItemGroup>
diff --git a/optimizerDuck/optimizerDuck.csproj b/optimizerDuck/optimizerDuck.csproj
index a9c5441..a32d2e1 100644
--- a/optimizerDuck/optimizerDuck.csproj
+++ b/optimizerDuck/optimizerDuck.csproj
@@ -17,6 +17,9 @@
<AssemblyDescription>Free, open-source Windows optimization tool for performance, privacy, and simplicity.</AssemblyDescription>
<NeutralLanguage>en-US</NeutralLanguage>
<ApplicationManifest>app.manifest</ApplicationManifest>
+ <!-- The gate: a warning fails the build, and the promoted style rules run inside it. -->
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">