Repository navigation
[patch] Scale Milliliter from the litre, not from cubic metres - #382
Merged
Merged
Conversation
Milliliter declared only a Milli magnitude, which the generator applies to the dimension's base unit. For Volume that is m³, so 1 mL was 1e-3 m³ (one litre). Give it the LiterToCubicMeters factor as well, making it 1e-6 m³, and regenerate. The rest of the magnitude-only units are prefixes of their dimension's base unit and were already right. A new test checks every SI-prefixed unit in the catalogue against its unprefixed unit, so this class of mistake fails the build. Fixes #286 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MZE6sRR8wRTGhthCM8sL2M
|
This was referenced Oct 6, 2026
This was referenced Oct 9, 2026
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 #286
What changed
Milliliterinunits.jsondeclared only"magnitude": "Milli". The generator applies a magnitude to the dimension's base unit, and for Volume that base unit is m³. As a result, 1 mL was converted as 1e-3 m³, which is one litre: 1000× too large. The entry now also declares"conversionFactor": "LiterToCubicMeters", soBuildToBaseFactorExpressionemits Milli × LiterToCubicMeters = 1e-6 m³.The committed generator output is regenerated, in three files:
Units.g.cs:Milliliter.ToBaseFactorandToBaseFactorAs<T>Volume.g.cs:FromMilliliterCapacity.g.cs:FromMilliliterAudit of the other magnitude-only units
All 29 other units that carry a
magnitudeare prefixes of their dimension's base unit, so they were already correct:Milliliter was the only one that was wrong.
Tests
In
UnitBackfillTests:Volume_FromMilliliter_Is_1e6_CubicMetersVolume_FromMilliliter_1000_Is_1_Liter, which covers bothVolumeandCapacityEveryPrefixedUnit_Is_ThePrefixTimesItsUnprefixedUnit, a catalogue-wide guard. It pairs every Pico, Nano, Micro, Milli, Centi, Kilo or Mega unit with its unprefixed unit when that unit exists, and asserts the factor is exactly the prefix times that unit's factor. This is the regression check the triage asked for.All 3 fail with the
units.jsonchange reverted and pass with it. The fullSemantics.Testsuite passes: 1449 passed, 8 skipped, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_01MZE6sRR8wRTGhthCM8sL2M
Generated by Claude Code