Summary
The QuantitiesGenerator produces a single From{Unit}(T value) static factory per quantity type, regardless of how many entries availableUnits has in dimensions.json. As a result, generated quantities expose only the SI base unit factory and there is no way to construct values from any of the other declared units.
Evidence
Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs:369-385 only iterates the first unit when emitting From* factories.
Confirmed in generated output, e.g. Semantics.Quantities/Generated/.../Mass.g.cs:
public static Mass<T> FromKilogram(T value) => Create(value);
There is no FromGram, FromMilligram, FromTonne, etc. Same pattern across every generated file (e.g. Length only emits FromMeter, with no FromCentimeter, FromKilometer, FromFoot, FromInch, FromYard, FromMile).
Impact
- The user-facing API documented in
docs/strategy-unified-vector-quantities.md (e.g. Speed.FromMetersPerSecond(...), Force1D.FromNewtons(...)) is partially missing for any non-base unit.
- Forces consumers to manually convert before calling
From{BaseUnit}, defeating a core ergonomics goal of the library.
Suggested next step
Update the generator to emit a From{Unit} factory for every entry in availableUnits, applying the unit's conversion factor (read from the units metadata / ConversionsGenerator) so the value is normalised to the SI base unit inside the factory.
Area / Severity
SourceGenerators · bug
Summary
The
QuantitiesGeneratorproduces a singleFrom{Unit}(T value)static factory per quantity type, regardless of how many entriesavailableUnitshas indimensions.json. As a result, generated quantities expose only the SI base unit factory and there is no way to construct values from any of the other declared units.Evidence
Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs:369-385only iterates the first unit when emittingFrom*factories.Confirmed in generated output, e.g.
Semantics.Quantities/Generated/.../Mass.g.cs:There is no
FromGram,FromMilligram,FromTonne, etc. Same pattern across every generated file (e.g.Lengthonly emitsFromMeter, with noFromCentimeter,FromKilometer,FromFoot,FromInch,FromYard,FromMile).Impact
docs/strategy-unified-vector-quantities.md(e.g.Speed.FromMetersPerSecond(...),Force1D.FromNewtons(...)) is partially missing for any non-base unit.From{BaseUnit}, defeating a core ergonomics goal of the library.Suggested next step
Update the generator to emit a
From{Unit}factory for every entry inavailableUnits, applying the unit's conversion factor (read from the units metadata /ConversionsGenerator) so the value is normalised to the SI base unit inside the factory.Area / Severity
SourceGenerators · bug