Skip to content

Document overriding built-in unit conversions - #1718

Merged
angularsen merged 1 commit into
masterfrom
agl-codex/issue-1313-conversion-overrides
Aug 1, 2026
Merged

Document overriding built-in unit conversions#1718
angularsen merged 1 commit into
masterfrom
agl-codex/issue-1313-conversion-overrides

Conversation

@angularsen

Copy link
Copy Markdown
Owner

Motivation

#1313 reported that custom conversion functions could not override built-in same-quantity conversions in v5. In v6, the supported model is to customize the quantity unit definitions before the converter is built, instead of adding runtime override precedence for built-in conversions.

Changes

  • Document how to override built-in unit conversion factors through UnitsNetSetup.ConfigureDefaults() or an isolated custom UnitConverter.
  • Add regression coverage for the original PressureUnit.InchOfWaterColumn scenario, verifying that UnitConverter, As(..., converter), and ToUnit(..., converter) all use the configured conversion factor.

Validation

  • dotnet test UnitsNet.Tests\UnitsNet.Tests.csproj --filter "FullyQualifiedName~UnitConverterTest.ConvertValue_WithCustomBuiltInUnitDefinition_UsesConfiguredConversion|FullyQualifiedName~UnitConverterTest.GetConversionFunction_WithCustomUnitConversion|FullyQualifiedName~UnitConverterTest.TryGetConversionFunction_WithCustomUnitConversion"

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98%. Comparing base (af17f9b) to head (c3259a4).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1718   +/-   ##
======================================
  Coverage      98%     98%           
======================================
  Files         514     514           
  Lines       24141   24141           
======================================
  Hits        23748   23748           
  Misses        393     393           
Flag Coverage Δ
net48 97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@angularsen
angularsen marked this pull request as ready for review August 1, 2026 20:58
@angularsen
angularsen merged commit e6ccd72 into master Aug 1, 2026
7 checks passed
@angularsen
angularsen deleted the agl-codex/issue-1313-conversion-overrides branch August 1, 2026 20:58
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