Skip to content

refactor!: extract optional metric conversions - #37

Merged
ScottishTapWater merged 6 commits into
mainfrom
refactor/metric-extension
Oct 25, 2026
Merged

ScottishTapWater merged 6 commits into
mainfrom
refactor/metric-extension

Conversation

@ScottishTapWater

@ScottishTapWater ScottishTapWater commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Move engineering unit definitions and conversions into the opt-in DimensionalQuantities.Extensions.Metric package.
  • Keep quantity identities, catalogue aliases, SI base helpers, arithmetic and diagnostics in core.
  • Share the seven SI unit symbol declarations from core; Metric references them, with names and symbols defined once for both declarations and the core unit model.
  • Discover attribute-based unit providers through Roslyn and compile their public helpers into each extension assembly using the ordinary generator reference.
  • Support compound factors, rational powers, scale/offset conversions and optional SI prefix helpers. Report invalid declarations as DQ0008.
  • Separate MetricSymbols from quantity associations, allow several quantities to share one unit declaration, and keep offsets on the shared UnitConversion declaration.
  • Clarify coordinator, reader and source-emitter naming, share generated-source binding, and keep project-specific settings in their project files.
  • Build and publish both packages together, with symbols, Source Link and embedded generated source.
  • Update installation/migration guidance, the diagnostics table and an extension-authoring example.

Verification

  • Release build: no warnings or errors.
  • Full suite: 993 tests passed, including six package integration tests. Removed obsolete unit-name tests and moved the remaining naming coverage to UnitExpression.
  • Six package integration tests cover core-only and Metric-only consumers, namespace opt-in, cross-package interoperability, matching PDBs, Source Link and embedded generated source.
  • Package checker validates both nupkg/snupkg pairs, exact dependency versions, analyzer propagation and repository metadata.
  • Formatting verification and independent C# production/test reviews passed, including an architectural comparison against origin/main.
  • Metric catalogue tests verify factories and accessors independently against known SI values.

Breaking change

Catalogue conversions such as Voltage.FromVolts, AsWatts, and catalogue-specific FromPrefixedUnits/AsPrefixedUnits require DimensionalQuantities.Extensions.Metric and using DimensionalQuantities.Extensions.Metric;.

Core retains quantity aliases, SI base helpers, arithmetic and generic SI conversion APIs. No new unit systems are shipped in this PR.

Move catalogue conversions into DimensionalQuantities.Extensions.Metric while retaining quantity identities and SI bases in core. Generate compiled extensions at build time and release both packages with symbols and Source Link.

BREAKING CHANGE: Catalogue conversions now require DimensionalQuantities.Extensions.Metric and its namespace. Core retains the aliases, arithmetic, and generic SI conversion APIs.
Remove the build console and custom execution target. Generate Metric extensions during compilation and organise conversion, API, and package tests around their owning components.
@ScottishTapWater
ScottishTapWater merged commit 502284e into main Oct 25, 2026
2 checks passed
@ScottishTapWater
ScottishTapWater deleted the refactor/metric-extension branch October 25, 2026 10:57
ScottishTapWater added a commit that referenced this pull request Oct 25, 2026
## Summary

Adds the opt-in `DimensionalQuantities.Extensions.Imperial` package on
top of #37. It provides British and US customary conversions for length,
area, volume, mass, speed, force, pressure, energy, power, and absolute
Fahrenheit temperature. US and Imperial liquid measures have distinct
method names; the BTU helper uses the International Table definition.

The provider generates no SI-prefixed helpers. Core gains
package-neutral `Speed` and `Force` quantity names. The package checker
now validates every extension included in the solution, and the README
shows how to use Imperial conversions.

## Verification

- Release solution build: 0 warnings, 0 errors.
- Full suite: 1,001 tests passed, including six Imperial tests and a
packaged consumer test.
- `dotnet pack` produced runtime and symbol packages; package layout
check passed.
- `dotnet format --verify-no-changes --no-restore` passed for changed C#
files.
- Independent production and test reviews found no actionable issues.

Conversion definitions follow [NIST SP
811](https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b8),
its [International Table BTU
footnote](https://www.nist.gov/pml/special-publication-811/nist-guide-si-footnotes),
and the [UK Units of Measurement
Regulations](https://www.legislation.gov.uk/uksi/1995/1804/schedule/made).
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.

1 participant