Storage-type aliases that bind every
ktsu.Semantics.Quantitiestype tofloat, so you writeMassinstead ofMass<float>, project-wide.
ktsu.Semantics.Quantities.Float is a satellite of ktsu.Semantics.Quantities in the ktsu.Semantics family. Read the core package README first for the quantity API itself.
Every quantity in ktsu.Semantics.Quantities is generic over its numeric storage type, so you normally write Mass<float>, Speed<float>, and so on. If a project uses one storage type throughout, that generic argument is noise.
This package is props-only. It ships no assembly, just a buildTransitive props file that injects one C# global-using alias per quantity, binding each open generic type to float. Reference it and you can write Mass, Speed, Force3D with no generic argument, and every quantity resolves to its float form. The aliases are real Mass<float> (and so on), so they interoperate with the entire API with no conversion.
Installing this package also pulls in the matching version of ktsu.Semantics.Quantities as a dependency, so it is the only reference you need.
Install-Package ktsu.Semantics.Quantities.Floatdotnet add package ktsu.Semantics.Quantities.Float<PackageReference Include="ktsu.Semantics.Quantities.Float" Version="x.y.z" />using ktsu.Semantics.Quantities; // types resolve to their float form via the injected aliases
Mass mass = Mass.FromKilogram(10.0f);
Speed speed = Speed.FromMeterPerSecond(15.0f);
Mass total = mass + Mass.FromKilogram(2.0f); // still a Mass<float>, full identity
Force3D f = new() { X = 3.0f, Y = 4.0f, Z = 0.0f };
ForceMagnitude mag = f.Magnitude(); // 5.0Under the hood the injected alias looks like this (one line per quantity, roughly 220 in total):
<Using Include="ktsu.Semantics.Quantities.Mass<float>" Alias="Mass" />The aliases are project-wide global usings keyed on the bare type name (Mass, Speed, ...). Referencing two flavor packages in the same project would define the same alias name twice (one bound to float, one to another type), which is a compile error. So reference exactly one of:
ktsu.Semantics.Quantities.Doublektsu.Semantics.Quantities.Float(this package)ktsu.Semantics.Quantities.Decimal
A project that genuinely needs mixed storage types should skip the alias packages and reference ktsu.Semantics.Quantities directly, writing the closed generic (Mass<float>) explicitly.
The alias lists are generated from the quantity catalogue by scripts/Generate-AliasProps.ps1 and validated in CI, so they stay in lockstep with the quantities the core package emits.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License. See the LICENSE.md file for details.