Skip to content

build: derive Containers.Benchmarks identity from ktsu.Sdk - #48

Merged
matt-edmondson merged 4 commits into
mainfrom
claude/nice-davinci-0jnod9
Sep 15, 2026
Merged

matt-edmondson merged 4 commits into
mainfrom
claude/nice-davinci-0jnod9

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #41

The change

Containers.Benchmarks declared raw Microsoft.NET.Sdk with no ktsu.Sdk import, so AssemblyName and RootNamespace were both hand-written — and had drifted apart. It now imports ktsu.Sdk and lets both derive from the solution-relative folder path.

Property Before After
AssemblyName Containers.Benchmarks ktsu.Containers.Benchmarks
RootNamespace ktsu.Containers.Benchmarks ktsu.Containers.Benchmarks
IsPackable true false
SonarQubeExclude true true

IsPackable was the one surprise: the issue assumed OutputType=Exe kept the harness off nuget.org, but it evaluated to true. It is now explicitly false, per the convention for non-shipping projects.

Build output goes from Containers.Benchmarks.dll to ktsu.Containers.Benchmarks.dll.

Analyzers the import brings with it

This was the risk the issue flagged, and it is real — the first build after the switch failed with 96 errors. Handled as follows:

  • KTSU0006 — the benchmark attributes ([MemoryDiagnoser], [SimpleJob], [Params]) come from BenchmarkDotNet.Annotations, used transitively. Now referenced directly, with a matching PackageVersion (0.15.8) in Directory.Packages.props.
  • KTSU0001 — Polyfill reference added, as the library has.
  • CA5394 (92 occurrences) — benchmarks seed Random with a fixed value so every run measures the same input sequence. That is CLAUDE.md's own benchmarking standard ("Use fixed random seed (new Random(42)) for reproducibility"); a cryptographic RNG would defeat it. Opted out at project scope with a justification comment.
  • KTSU0002 — suggests InternalsVisibleTo for the test project. Nothing tests the benchmark harness. Same opt-out.

The opt-outs are NoWarn on the benchmarks project only, so nothing is relaxed for the library or the tests. The existing SonarQubeExclude property and its justification are untouched.

Regression guard

ProjectConventionTests asserts, over the repository's own .csproj files, that every project imports ktsu.Sdk and that none hand-writes AssemblyName or RootNamespace.

Verified by reverting the fix and re-running — both tests fail, each naming the offending project:

EveryProject_ImportsKtsuSdk
  These projects do not import ktsu.Sdk, so their identity is not derived: Containers.Benchmarks.csproj
NoProject_HandWritesAssemblyNameOrRootNamespace
  ktsu.Sdk derives both values from the folder path; these projects override them:
  Containers.Benchmarks.csproj (AssemblyName and RootNamespace)

With the fix restored, both pass.

One unrelated commit, please read

df397d9 is not part of this issue and can be split out if you would rather take it separately.

Containers.Test does not compile on current .NET 10 SDKs: array[0..4] in OrderedSetTests.CopyTo_ValidParameters_CopiesElements is rejected as CA1832. This already fails the .NET workflow on main across ubuntu, windows and macos (run 482) — global.json pins 10.0.100 with rollForward: latestFeature, so runners roll forward into the 10.0.4xx band where the rule fires.

I included the fix because the new conventions test lives in that project and cannot build or run in CI without it. AsSpan, which the rule recommends, is not usable here — Assert.AreSequenceEqual takes an IEnumerable<T>. Take(4) expresses the same intent and copies nothing.

Verification

  • dotnet build -c Release — succeeds, 0 warnings, 0 errors, all target frameworks
  • dotnet test — 357/357 pass, including the 2 new tests
  • Benchmarks emit ktsu.Containers.Benchmarks.dll

Part of the estate-wide naming audit tracked in ktsu-dev/Sdk#36.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CdAs5Q7rxgumCR8KraGer1


Generated by Claude Code

Containers.Benchmarks declared raw Microsoft.NET.Sdk with no ktsu.Sdk import,
so AssemblyName and RootNamespace were both hand-written and had drifted apart:
the assembly was Containers.Benchmarks while the namespace was
ktsu.Containers.Benchmarks.

Import ktsu.Sdk alongside Microsoft.NET.Sdk and drop both overrides, so each
derives from the solution-relative folder path as ktsu.Containers.Benchmarks.
Set IsPackable=false explicitly rather than relying on OutputType=Exe; it
evaluated to true before this change.

Pulling in ktsu.Sdk applies its analyzers to the benchmark harness, which needs
three adjustments:

- KTSU0006: reference BenchmarkDotNet.Annotations directly, since the benchmark
  attributes come from it rather than from BenchmarkDotNet itself.
- KTSU0001: reference Polyfill, as the library does.
- CA5394 and KTSU0002: opt out at project scope with a justification. Benchmarks
  seed Random with a fixed value on purpose so every run measures the same input
  sequence, and nothing tests the harness.

The existing SonarQubeExclude property and its justification are unchanged.

Fixes #41

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdAs5Q7rxgumCR8KraGer1
…ity [patch]

Two conventions tests over the repository's own project files, so the drift
fixed in the previous commit cannot come back silently:

- every .csproj imports ktsu.Sdk
- no .csproj hand-writes AssemblyName or RootNamespace

Both fail against the previous Containers.Benchmarks.csproj, naming the
offending project in the assertion message.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdAs5Q7rxgumCR8KraGer1
…ects [patch]

Containers.Test has not compiled since the analyzers began flagging
array[0..4] in CopyTo_ValidParameters_CopiesElements as CA1832, which fails
the .NET workflow on main across all three platforms. AsSpan, which the rule
recommends, is not an option here: Assert.AreSequenceEqual takes an
IEnumerable<T>. Take(4) expresses the same intent and allocates no copy.

This is pre-existing on main and unrelated to the rest of this branch, but the
new conventions test cannot build or run in CI without it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdAs5Q7rxgumCR8KraGer1
Comment thread Containers.Test/ProjectConventionTests.cs Fixed
Replace `== true` with `?? false`, which keeps the same null semantics and
drops the redundant comparison CodeQL flagged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdAs5Q7rxgumCR8KraGer1
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit fd0ff63 into main Sep 15, 2026
13 checks passed
@matt-edmondson
matt-edmondson deleted the claude/nice-davinci-0jnod9 branch September 15, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Containers.Benchmarks skips ktsu.Sdk, so its assembly name is unprefixed

2 participants