You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Volume.FromMilliliter(1) is 1 litre (1e-3 m³), 1000× too large: Milli prefix is applied to m³ instead of the litre #286
UnitsGenerator.BuildToBaseFactorExpression applies the magnitude to the dimension's SI base unit. For Volume that base unit is m³, not the litre, so the generated ToBaseFactor is MetricMagnitudes.Milli = 1e-3 m³. That is one litre. The correct factor is 1e-6 m³.
The same pattern gives correct results elsewhere only because those units are prefixed forms of the base unit itself. For example, Gram = Milli × kg = 1e-3 kg is correct, and Millimeter = Milli × m is correct. The litre is not the base unit of Volume, so the prefix alone is wrong here.
Failure scenario
Volume<double>.FromMilliliter(1.0).Value returns 0.001 (m³). It should return 1e-6.
Everything that goes through the unit's factor is off by 1000×: Capacity.FromMilliliter, IUnit.ToBaseFactor, ToBaseFactorAs<T>(), and every In(new Milliliter()).
For example, 5 mL of a dose or reagent comes out as 5 L. No test references Milliliter, so nothing catches this.
Check the other units in units.json that carry a magnitude in dimensions whose base unit is not the unprefixed form of that unit. Any new ones found get the same treatment and a test.
Priority: High. FromMilliliter is off by 1000× and nothing fails, so 5 mL silently becomes 5 L. It flows through ToBaseFactor, In(...) and Capacity, and no test covers it.
Area / suggested assignee:Semantics.SourceGenerators/Metadata/units.json (the Milliliter entry) and UnitsGenerator.BuildToBaseFactorExpression. Owner: @matt-edmondson
Next step: Add "conversionFactor": "LiterToCubicMeters" to Milliliter and regenerate. Then audit every magnitude-bearing unit whose dimension's base unit isn't that unit's unprefixed form, for example other litre-based units or prefixed non-SI units. A generator-side check or a test that round-trips every unit against a known value would stop this class of bug from coming back.
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
FromMilliliteris off by 1000× and nothing fails, so 5 mL silently becomes 5 L. It flows throughToBaseFactor,In(...)andCapacity, and no test covers it.Semantics.SourceGenerators/Metadata/units.json(theMilliliterentry) andUnitsGenerator.BuildToBaseFactorExpression. Owner: @matt-edmondson"conversionFactor": "LiterToCubicMeters"toMilliliterand regenerate. Then audit everymagnitude-bearing unit whose dimension's base unit isn't that unit's unprefixed form, for example other litre-based units or prefixed non-SI units. A generator-side check or a test that round-trips every unit against a known value would stop this class of bug from coming back.Generated by Claude Code