镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Alias QFactor and NormalizedParameter in every storage-type package [patch] - #545

Open
matt-edmondson wants to merge 2 commits into
mainfrom
fix/541-alias-handwritten-quantities
Open

matt-edmondson wants to merge 2 commits into
mainfrom
fix/541-alias-handwritten-quantities

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #541

What changed

QFactor<T> and NormalizedParameter<T> are written by hand and have no generated .g.cs. scripts/Generate-AliasProps.ps1 builds its catalogue only from generated files, so none of the four alias packages bound these two types.

  • Script: a $handWrittenTypes list now joins the generated catalogue. It holds NormalizedParameter and QFactor. Hand-written partials of generated types, such as Gain and Decibels, still need no entry.
  • Props: all four build/ktsu.Semantics.Quantities.*.props files are regenerated and now carry 231 aliases each, two more than before. verify-generated.yml stays in sync, because the props are the script's output.
  • Guard test: AliasPropsPackagingTests.EveryAliasPackageAliasesEveryPublicGenericQuantityType lists every public, non-nested, single-parameter generic value type in ktsu.Semantics.Quantities by reflection. It fails when any of them is missing from any of the four props. A future hand-written type is caught there, and the failure message says where to add it.

I took the explicit-list option from the issue. Building the catalogue from the compiled assembly would have made the script depend on a build. The reflection test gives the same protection without that dependency.

Verification

  • With the script change in place but the props not yet regenerated, the new test fails and names both types in all four packages. After regenerating, it passes.
  • In a throwaway consumer project that imports the Double props and then the Precise props, QFactor q = default; NormalizedParameter p = default; compiles.
  • The full Semantics.Test suite passes on net10.0: 1996 passed, 14 skipped, 0 failed.

Generated by Claude Code

…patch]

Both are hand-written generic quantity types with no generated .g.cs,
so Generate-AliasProps.ps1 never put them in its catalogue and none of
the four alias packages bound them. The script now adds a short list of
hand-written types, and a test fails when a public generic value type in
ktsu.Semantics.Quantities has no alias in any of the props.

Fixes #541

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

Copy link
Copy Markdown
Contributor Author

SonarCloud Code Analysis is red: "0.0% Coverage on New Code (required ≥ 80%)". The gap is structural. It isn't a missing test.

  • The SonarCloud API (measures/component_tree for this PR) shows the only coverable new code is 3 lines in scripts/Generate-AliasProps.ps1. The new C# test is excluded from coverage by the shared pipeline's **/*Test*.cs pattern, and the regenerated .props files aren't counted as code.
  • The shared dotnet.yml imports only .NET coverage (sonar.cs.vscoveragexml.reportsPaths). No PowerShell coverage is collected, so any edit to a .ps1 file reads as 0% new-code coverage, however it's tested. The script's output is still checked. verify-generated.yml regenerates the props and diffs them, and that check passes. The new EveryAliasPackageAliasesEveryPublicGenericQuantityType test also fails if the script leaves out a type.
  • The gate doesn't block anything here. main has no required checks, and the release gate is opt-in through SONAR_BLOCKING_GATE. Analyze & Release, all three test legs, CodeQL and the generated-files check are green.

I can't fix this from inside the PR. The pipeline already has a per-repository escape hatch for it: setting the SONAR_COVERAGE_EXCLUSIONS_EXTRA repository variable to scripts/** excludes these generator scripts from coverage, as it does for other files that can't be measured. That's a repository setting, so I've left it for the maintainer to decide.


Generated by Claude Code

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants