build: derive Containers.Benchmarks identity from ktsu.Sdk - #48
Merged
Merged
Conversation
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
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
|
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.



Fixes #41
The change
Containers.Benchmarksdeclared rawMicrosoft.NET.Sdkwith noktsu.Sdkimport, soAssemblyNameandRootNamespacewere both hand-written — and had drifted apart. It now importsktsu.Sdkand lets both derive from the solution-relative folder path.AssemblyNameContainers.Benchmarksktsu.Containers.BenchmarksRootNamespacektsu.Containers.Benchmarksktsu.Containers.BenchmarksIsPackabletruefalseSonarQubeExcludetruetrueIsPackablewas the one surprise: the issue assumedOutputType=Exekept the harness off nuget.org, but it evaluated totrue. It is now explicitlyfalse, per the convention for non-shipping projects.Build output goes from
Containers.Benchmarks.dlltoktsu.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:
[MemoryDiagnoser],[SimpleJob],[Params]) come fromBenchmarkDotNet.Annotations, used transitively. Now referenced directly, with a matchingPackageVersion(0.15.8) inDirectory.Packages.props.Polyfillreference added, as the library has.Randomwith a fixed value so every run measures the same input sequence. That isCLAUDE.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.InternalsVisibleTofor the test project. Nothing tests the benchmark harness. Same opt-out.The opt-outs are
NoWarnon the benchmarks project only, so nothing is relaxed for the library or the tests. The existingSonarQubeExcludeproperty and its justification are untouched.Regression guard
ProjectConventionTestsasserts, over the repository's own.csprojfiles, that every project importsktsu.Sdkand that none hand-writesAssemblyNameorRootNamespace.Verified by reverting the fix and re-running — both tests fail, each naming the offending project:
With the fix restored, both pass.
One unrelated commit, please read
df397d9is not part of this issue and can be split out if you would rather take it separately.Containers.Testdoes not compile on current .NET 10 SDKs:array[0..4]inOrderedSetTests.CopyTo_ValidParameters_CopiesElementsis rejected asCA1832. This already fails the .NET workflow onmainacross ubuntu, windows and macos (run 482) —global.jsonpins10.0.100withrollForward: 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.AreSequenceEqualtakes anIEnumerable<T>.Take(4)expresses the same intent and copies nothing.Verification
dotnet build -c Release— succeeds, 0 warnings, 0 errors, all target frameworksdotnet test— 357/357 pass, including the 2 new testsktsu.Containers.Benchmarks.dllPart 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