DimensionalQuantities 1.2.0
See the version list below for details.
dotnet add package DimensionalQuantities --version 1.2.0
NuGet\Install-Package DimensionalQuantities -Version 1.2.0
<PackageReference Include="DimensionalQuantities" Version="1.2.0" />
<PackageVersion Include="DimensionalQuantities" Version="1.2.0" />
<PackageReference Include="DimensionalQuantities" />
paket add DimensionalQuantities --version 1.2.0
#r "nuget: DimensionalQuantities, 1.2.0"
#:package DimensionalQuantities@1.2.0
#addin nuget:?package=DimensionalQuantities&version=1.2.0
#tool nuget:?package=DimensionalQuantities&version=1.2.0
DimensionalQuantities
A C# library for dimensional quantities, with generated type aliases, SI unit conversions, and compile-time dimensional arithmetic.
We developed this library for our own internal use and are sharing it because we believe it may be useful to the wider developer community. Issues and pull requests are welcome, but we make no support commitments or warranties, and we cannot guarantee that we will respond to issues or review or merge pull requests.
Usage
Requires .NET 10 and C# 14. The DimensionalQuantities NuGet package includes both the runtime library and its source generator.
Voltage voltage = Voltage.FromVolts(12);
Current current = Current.FromAmps(3);
Resistance resistance = voltage / current;
Power power = voltage * current;
double ohms = resistance.AsOhms(); // 4
double watts = power.AsWatts(); // 36
SI prefixes and compound units
Named helpers handle conversion into and out of SI prefixes, including powers of prefixed units:
Length length = Length.FromMilliMetres(2500);
double metres = length.AsMetres(); // 2.5
Density density = Density.FromGramsPerCubicCentiMetre(1);
double kilogramsPerCubicMetre = density.AsSiBaseUnit(); // 1000
For more control, FromPrefixedUnits and AsPrefixedUnits accept decimal prefix exponents for each unit factor. Powers are taken into account automatically:
// 1 A/mm² = 1,000,000 A/m²
CurrentDensity density = CurrentDensity.FromPrefixedUnits(
1, ampPrefixExponent: 0, metrePrefixExponent: -3);
double ampsPerSquareMillimetre = density.AsPrefixedUnits(
ampPrefixExponent: 0, metrePrefixExponent: -3); // 1
Named compound units remain a single factor where appropriate: Voltage.FromPrefixedUnits(2, -3) means 2 millivolts, without requiring you to know the SI dimensions of a volt.
Arithmetic and generated intermediate quantities
The generator follows multiplication and division through nested expressions, derives their dimensions, and generates the required operators and intermediate aliases:
Current current = Current.FromAmps(3);
Resistance resistance = Resistance.FromOhms(4);
CurrentSquared squared = current * current;
Power heating = current * current * resistance; // 36 W
Current doubled = 2 * current;
Current halved = current / 2;
Frequency frequency = 1 / Time.FromSeconds(0.02); // 50 Hz
Known dimensions use names from the engineering catalogue, such as Power, Voltage, Permeability and MagneticFluxDensity. Other dimensions receive mechanical names such as CurrentSquared or TimePerCurrent. Discovered quantities have SI base-unit and generic prefix conversion helpers.
Aliases with the same dimensions share a type. For example, Energy and Torque are interchangeable: the library checks dimensions, not the physical meaning of a calculation. Magnitudes are stored as double in coherent SI base units.
Current scope
Arithmetic discovery currently supports multiplication and division with known quantity operands, scalar factors, nested expressions, and intermediate var locals inferred through their initialisers. Roots, powers, dimensionless results and inference through unresolved explicit type names are not yet supported by discovery.
The library is under active development; the API and supported expression patterns are still evolving.
Licence
MIT, copyright GoSim.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on DimensionalQuantities:
| Package | Downloads |
|---|---|
|
DimensionalQuantities.Extensions.Nautical
Named nautical conversions for dimensional quantities. |
|
|
DimensionalQuantities.Extensions.Metric
Named metric conversions for dimensional quantities. |
|
|
DimensionalQuantities.Extensions.CgsEmag
Named CGS electromagnetic and mechanical conversions for dimensional quantities. |
|
|
DimensionalQuantities.Extensions.Imperial
Named Imperial and US customary conversions for dimensional quantities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.1 | 183 | 10/27/2026 |
| 2.2.0 | 181 | 10/27/2026 |
| 2.1.0 | 246 | 10/25/2026 |
| 2.0.1 | 249 | 10/25/2026 |
| 2.0.0 | 262 | 10/25/2026 |
| 1.8.0 | 104 | 10/24/2026 |
| 1.7.0 | 91 | 10/24/2026 |
| 1.6.0 | 90 | 10/24/2026 |
| 1.5.0 | 90 | 10/24/2026 |
| 1.4.0 | 95 | 10/24/2026 |
| 1.3.0 | 89 | 10/24/2026 |
| 1.2.0 | 94 | 10/22/2026 |
| 1.1.0 | 86 | 10/22/2026 |
| 1.0.0 | 92 | 10/22/2026 |