build: raise the analyzer rules to error and fix the reported code - #2299
Merged
Conversation
- Every dotnet_diagnostic severity is now error. - Adds the newest analyzer rules: SST1535, SST1536, SST1537, SST2019, SST2497, SST2498 and PSH1023. - The file is now identical across refit, reactiveui, Primitives, splat and Akavache apart from file_header_template.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2299 +/- ##
==========================================
- Coverage 99.95% 99.91% -0.05%
==========================================
Files 192 192
Lines 10104 10031 -73
Branches 1926 1925 -1
==========================================
- Hits 10099 10022 -77
- Partials 5 9 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Enable every StyleSharp, PerformanceSharp, SecuritySharp and public API rule as an error, except those that conflict with an existing setting. - Record the conflict in a comment beside each rule left disabled. - Track the var-versus-explicit preference through stylesharp.use_var so the rule follows the csharp_style_var_* settings already in the file. - Fix the reported code across the runtime, generator, analyzer, test, benchmark and example trees. - Describe when each documented exception is thrown rather than naming the type alone. - Map RootObject to its JSON field names explicitly rather than relying on the property identifiers matching. - Update the analyzer packages and regenerate the public API baselines.
glennawatson
force-pushed
the
build/analyzer-rules-error
branch
from
August 8, 2026 04:35
43a5321 to
bfa2c3d
Compare
|
ChrisPulman
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What kind of change does this PR introduce?
build
What is the new behavior?
Every StyleSharp, PerformanceSharp, SecuritySharp and public API rule is an error, and the code they reported is fixed.
suggestionorwarning, so the build fails on any of them rather than accumulating advisories.SST1118cannot hold withstylesharp.max_line_length = 200- 18 of its 41 sites do not fit on one line, the longest reaching 429 characters.SST1417derives the expected namespace from the folder, so a type that deliberately lives in a BCL namespace has no satisfying layout.SST1533reports a file that declares no type, which is what an#if-guarded polyfill looks like on frameworks that already have the API.SST1416demotes a public member of a non-public type to internal. That is not safe here:Type.GetPropertyandActivator.CreateInstance(Type)use binding flags that see public members only, so the demotion compiles and then changes behaviour.SST1609requires a<value>element that only ever restates the<summary>.stylesharp.use_varis set toalways, so the var-versus-explicit rule follows thecsharp_style_var_*preferences already in the file instead of its own default..editorconfigeach tree already has - debugger-display and inlining attributes on test types, and identical benchmark bodies, which are the design of a[GlobalSetup(Target = ...)]benchmark rather than a copy that was meant to differ.RootObjectmaps to its JSON field names with[JsonPropertyName]. It previously relied on the property identifiers happening to spell_idand_rev, so the contract was invisible to a reader and broke under a rename.<exception>elements name the condition that reaches the throw, rather than naming the type and leaving the reader to find the guard.What is the current behavior?
Most of these rules were disabled, advisory or warning-level, so their findings never failed a build. The two
.editorconfigfiles that relax rules for the test and benchmark trees did not cover the rules newly raised here, and a documented exception named only its type.What might this PR break?
Checklist
mainbranchAdditional information
Most of the diff is analyzer fix output and regenerated public API baselines. The hand-written parts worth review are:
.editorconfig,src/tests/.editorconfig,src/benchmarks/.editorconfig- the severities and the recorded conflicts.src/Refit/ApiResponse{T}.cs- the disposal guard is now an interlocked latch.src/InterfaceStubGenerator.Shared/Emitter.csandPooledStringBuilder.cs- the interpolated-string builder drops its_hasContentfield and derives the same answer from the buffer length, which needed a newLengthmember.src/InterfaceStubGenerator.Shared/InterfaceStubGeneratorV2.cs- the two candidate-combining methods no longer split their body across#if, and the empty-array guards now apply on both Roslyn versions.src/Refit/SystemTextJsonStreamingDeserializer.csandCamelCaseStringEnumConverter.cs- duplicate bodies now delegate.src/tests/Refit.Tests/RootObject.cs- the explicit JSON field mapping.GeneratedRequestRunner.BuildRequestPathand the generator's parse result are PascalCase. These are compile-time names only; generated code builds the tuples positionally.