Skip to content

Build with StyleCop.Analyzers 1.3, and inject 1.3.133-beta - #401

Merged
rdeago merged 15 commits into
Tenacom:mainfrom
rdeago:stylecop-analyzers-1.3
Oct 20, 2026
Merged

rdeago merged 15 commits into
Tenacom:mainfrom
rdeago:stylecop-analyzers-1.3

Conversation

@rdeago

@rdeago rdeago commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Checklist of related issues / discussions

  • Closes #
  • Part of #
  • Related discussion(s): #

Proposed changes

#400 moved the StyleCop.Analyzers injection to 1.3.79-beta, and this repository builds with that version since it pinned Buildvana SDK 2.1.781-preview.
This PR fits the code and the configuration of this repository to StyleCop.Analyzers 1.3, and moves the injection to 1.3.133-beta.

  • PackageVersions.props moves StyleCop.Analyzers from 1.3.79-beta to 1.3.133-beta.
    1.3.133-beta adds SA1143, SA1315, SA1654, and SX1412.
    The pin reaches this repository at the next release of Buildvana SDK.
    A build of this repository with 1.3.133-beta, through a Directory.Packages.props override, reports no StyleCop diagnostic.
  • .globalconfig lists every StyleCop rule of 1.3.133-beta with an explicit severity, and every rule set to none has a comment that says why.
    • SA1516 goes back to warning.
      1.2.0-beta.556 predates C# 12, and reported the rule on syntax it did not understand.
    • SA1141, SA1142, SA1315, SA1317, SA1653, SA1654, and SX1412 are warning.
      SX1412 replaces SA1412, so a C# file with a BOM fails the build.
    • SA1143 is none.
      Its chain layout ends each line with ? or :, and the "Concatenated ternaries" template of csharp-style-guide.md starts each line with :.
    • SA1500 is none.
      It rejects an opening brace at the end of a line, and has no option for expression braces.
      Its maintainer refused one in Alternative brace placement DotNetAnalyzers/StyleCopAnalyzers#3776.
      Three ReSharper inspections in .editorconfig take over the check, and they follow the formatter settings of this repository.
  • The StyleCop settings move from stylecop.json to a settings section of .globalconfig, which lists every setting, defaults included.
    StyleCop.Analyzers reads each setting from a stylecop.* key, and stylecop.json only overrode the keys.
    The settings section holds the StyleCop defaults for companyName and copyrightText, and the solution-specific overrides at the end of .globalconfig set the values of this repository.
    Buildvana.slnx, CODEOWNERS, labeler.yml, and file-formats.md no longer name stylecop.json.
  • The code moves to the layout the new rules enforce:
    • The opening brace of an initializer, a switch expression, a collection expression, a with expression, or a lambda block goes at the end of the line, not on a line of its own.
    • A multi-line collection expression has a trailing comma (SA1413).
      A spread over a LINQ chain gets a line of its own, so that the comma can end the chain.
    • VirtualTerminal uses nint instead of IntPtr (SA1121).
    • CommandParameters and GitService.CommitterIdentity get the blank lines SA1115 and SA1516 ask for.
  • inspect.cs gives inspectcode an empty cache directory under .buildvana-temp on every run.
    inspectcode reused its cached results for unchanged files, so a change to the inspection settings reached only the changed files.
  • buildvana.jsonc and buildvana.next.jsonc give Microsoft.Build, Microsoft.Build.Framework, Microsoft.Build.Tasks.Core, and Microsoft.Build.Utilities.Core a patch policy, which keeps them at 18.9.x.
    Microsoft.Build 18.10.1 and later target net11.0, so the restore of Buildvana.Sdk.Tests failed with NU1701 under the default minor policy.
    The policy names the four ids, because other Microsoft.Build.* packages, such as Microsoft.Build.Locator and Microsoft.Build.NoTargets, have versions of their own.
  • The four Microsoft.Extensions.* pins move from 10.0.11 to 10.0.13, TUnit from 1.66.10 to 1.75.0, and the .NET SDK in global.json from 10.0.400 to 10.0.402.
  • Three files had lines over the 140-character limit, or a declaration over the 120-character limit, and are now wrapped.

Additional changes

  • PinDumpFixture.DumpPins and WritePackagePinDumpTests.ReadDumpAsync throw an InvalidOperationException with the file path when a pin dump file holds null.
    They suppressed the null result of JsonSerializer.Deserialize with !, so a test failed later with a NullReferenceException that named no file.
  • standard-analyzers.md said that a project without a stylecop.json file runs StyleCop with its default settings.
    The page now says that StyleCop also reads each setting from a key of .editorconfig or .globalconfig.

Types of changes

This pull request introduces the following types of changes:

  • Bug fix
  • New feature
  • Test addition / update (no changes to non-test code)
  • Refactor (no changes in public API syntax or semantics)
  • Performance improvement (no changes in public API syntax or semantics)
  • Documentation update (not including changelog)
  • Dependency addition / update
  • Changes to toolchain configuration
  • Changes to CI (workflows, bot / app configurations)
  • Changes to repository files (.gitattributes, .gitignore)
  • Other

Breaking changes

This pull request introduces breaking changes:

  • Yes
  • No

Checklist

  • For all types of changes:
  • For code changes only:
    • The project builds on my machine, via the provided build script, with zero warnings
    • I have added tests that prove my feature works / my fix is effective
    • I have added / modified XML documentation according to changes in code
    • I have checked that all the links I added or modified in XML documentation point to their intended destination
  • For documentation changes only:
    • I have checked and proofread documentation locally
    • I have checked that all the links I added or modified point to their intended destination

🤖 Generated with Claude Code

rdeago and others added 14 commits October 20, 2026 00:25
.globalconfig had SA1516 at none, because StyleCop.Analyzers 1.2.0-beta.556
predates C# 12 and reported the rule on syntax it did not understand.
1.3.79-beta audits every rule against C# 8 to 15, so SA1516 goes back to
warning. SA1141, SA1142, SA1317, and SA1653 get an explicit severity,
because the file lists every StyleCop rule. Every rule set to none gets a
comment saying why.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
StyleCop.Analyzers 1.3.79-beta reports IntPtr under SA1121, which asks for
the built-in alias nint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SA1500 reports an initializer, switch expression, or collection expression
whose opening brace ends a line. The ReSharper formatter settings of this
repository put that brace at end of line, and SA1500 has no option to
accept it. Three ReSharper inspections take over the check, and they follow
the formatter settings. One more formatter setting keeps auto-properties on
one line, which the inspections would otherwise split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inspectcode's rather aggressive result caching can cause inspect.cs
to report false positives and false negatives.
Now inspect.cs forces inspectcode to use a temporary cache directory
under `.buildvana-temp` and cleans it before every invocation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Initializers, switch expressions, collection expressions, with expressions,
and lambda blocks need not have their opening brace on a line of its own.
Updated analyzer rules enforce this, so this commit applies the rule
to existing code to avoid code analysis warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StyleCop.Analyzers 1.3.79-beta reports SA1413 on a multi-line collection
expression whose last element has no trailing comma. A spread over a LINQ
chain gets a line of its own, so that the comma can end the chain. The
closing bracket then stands alone, as in an element list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`PinDumpFixture.DumpPins` and `WritePackagePinDumpTests.ReadDumpAsync`
suppressed a null result of `JsonSerializer.Deserialize` with `!`. When a
pin dump file held `null`, a test failed later with a
`NullReferenceException` that named no file.
Both sites now throw an `InvalidOperationException` with the file path
instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StyleCop.Analyzers 1.3.79-beta reports SA1115 on the Forwarded parameter of
CommandParameters, because a blank line separates it from the previous
parameter. SA1515 accepts the comment above Forwarded without that blank
line. SA1516 reports the set accessor of GitService.CommitterIdentity,
because no blank line separates it from the get accessor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ExcludeFromCodeCoverage justification of
VirtualTerminal.TryEnableOnStandardError and the Options parameter
comment of CommandParameters exceeded 140 characters. The declaration of
OverrideSelector.SelectForCentralPin exceeded the 120-character limit
for declarations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under the default `minor` policy, `bv deps update` moved the
`Microsoft.Build*` pins to 18.11.0. `Microsoft.Build` 18.10.1 and later
target `net11.0` instead of `net10.0`, so the restore of
`Buildvana.Sdk.Tests` failed with NU1701. A newer pin would also compile
`Buildvana.Sdk.Tasks` against APIs missing from MSBuild 18.9, the
`BV_MinMSBuildVersion` floor. A `patch` policy keeps the
`Microsoft.Build*` pins at that floor. `Microsoft.Build.Locator` keeps
`minor`, because it has versions of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Buildvana SDK injected `StyleCop.Analyzers` 1.3.79-beta, which has no
SA1315, SA1654, or SX1412. An override that renamed a parameter, a `cref`
with escaped angle brackets, and a C# file with a BOM all passed the
build. `.globalconfig` sets the three rules to `warning`, and SX1412
takes the place of SA1412. 1.3.133-beta also adds SA1143, whose chain
layout ends each line with `?` or `:`. The "Concatenated ternaries"
template of `csharp-style-guide.md` starts each line with `:` instead,
so SA1143 is `none`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StyleCop.Analyzers reads every setting from a `stylecop.*` key of `.globalconfig`, and `stylecop.json` only overrode those keys. Keeping both files split the StyleCop configuration in two. The new settings section of `.globalconfig` lists every setting with its value, defaults included, as `.globalconfig` already lists every StyleCop rule. StyleCop reads three settings from standard keys, such as `csharp_using_directive_placement`. Those settings stay implicit, because the standard keys already hold the values `stylecop.json` set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`standard-analyzers.md` said that a project without a `stylecop.json` file runs StyleCop with its default settings. StyleCop.Analyzers also reads each setting from a key of `.editorconfig` or `.globalconfig`, and a value in `stylecop.json` wins over the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The StyleCop settings section of `.globalconfig` set
`stylecop.documentation.companyName` and
`stylecop.documentation.copyrightText` to the values of this repository.
Every other setting above the solution-specific overrides holds a value
that does not depend on the repository. The settings section now holds
the StyleCop defaults for both, and the overrides set the values of this
repository. Roslyn keeps the last value of a key repeated in one section,
so the overrides win.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:build [issue/PR] affects project files and/or build settings. area:docs [issue/PR] affects documentation (excluding XML documentation that is part of source code). area:repo [issue/PR] affects repository settings, e.g. issue templates. area:code [issue/PR] affects project code (excluding tests). area:deps [issue/PR] adds, updates, or removes dependencies. area:style [issue/PR] affects editor / code analysis settings. labels Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.85714% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.97%. Comparing base (01ca4cc) to head (5cff33d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...verAdapters/Internal/GitHub/GitHubServerAdapter.cs 0.00% 5 Missing ⚠️
.../Buildvana.Core.Json/Schema/JsonSchemaValidator.cs 0.00% 0 Missing and 3 partials ⚠️
...Sdk.Tasks/Internal/JetBrainsAnnotationsExporter.cs 0.00% 3 Missing ⚠️
...a.Core.Configuration/BuildvanaJsonConfigExample.cs 33.33% 0 Missing and 2 partials ⚠️
.../Buildvana.Core.Json/Schema/JsonSchemaGenerator.cs 33.33% 0 Missing and 2 partials ⚠️
.../Services/Dependencies/DependencyReportRenderer.cs 33.33% 0 Missing and 2 partials ⚠️
...dvana.Core.Configuration/BuildvanaConfigFactory.cs 92.30% 0 Missing and 1 partial ⚠️
....Core.Configuration/BuildvanaJsonConfigProvider.cs 66.66% 0 Missing and 1 partial ⚠️
...Buildvana.Core.ConsoleOutput/TextWriterReporter.cs 0.00% 0 Missing and 1 partial ⚠️
.../Buildvana.Core.IO/Gitignore/GitignoreCharClass.cs 0.00% 0 Missing and 1 partial ⚠️
... and 16 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #401      +/-   ##
==========================================
- Coverage   83.06%   82.97%   -0.10%     
==========================================
  Files         284      284              
  Lines        8475     8359     -116     
  Branches     1645     1645              
==========================================
- Hits         7040     6936     -104     
+ Misses       1158     1146      -12     
  Partials      277      277              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdeago rdeago left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Claude. Self-review.

⚠️ Changes requested.


One blocking finding. The Microsoft.Build* policy pattern also matches Microsoft.Build.NoTargets, and holds it to patch updates. That package is an MSBuild project SDK with versions of its own. The comment on buildvana.jsonc has the details.

The codecov/patch and codecov/project checks fail on the head commit. Ric accepted both failures for this review.

Comment thread buildvana.jsonc Resolved
The `Microsoft.Build*` pattern in the `dependencies.policies` of
`buildvana.jsonc` and `buildvana.next.jsonc` also matched the
`Microsoft.Build.NoTargets` pin in `global.json`. `dotnet bv deps update`
would then never move that pin to a new minor version. The package has
versions of its own, as `Microsoft.Build.Locator` does, and so do other
`Microsoft.Build.*` packages on NuGet. The `patch` policy therefore goes
to `Microsoft.Build`, `Microsoft.Build.Framework`,
`Microsoft.Build.Tasks.Core`, and `Microsoft.Build.Utilities.Core` by id.
Every other `Microsoft.Build.*` pin gets the default policy of its scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rdeago rdeago left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Claude. Self-review.

👍 Approved.


No blocking findings.

The codecov/patch and codecov/project checks fail on the head commit. Ric accepted both failures for this review.

@rdeago
rdeago merged commit a7cd79d into Tenacom:main Oct 20, 2026
5 of 7 checks passed
@rdeago
rdeago deleted the stylecop-analyzers-1.3 branch October 20, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:build [issue/PR] affects project files and/or build settings. area:code [issue/PR] affects project code (excluding tests). area:deps [issue/PR] adds, updates, or removes dependencies. area:docs [issue/PR] affects documentation (excluding XML documentation that is part of source code). area:repo [issue/PR] affects repository settings, e.g. issue templates. area:style [issue/PR] affects editor / code analysis settings.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant