Magnitudo 0.2.0-alpha.1
See the version list below for details.
dotnet add package Magnitudo --version 0.2.0-alpha.1
NuGet\Install-Package Magnitudo -Version 0.2.0-alpha.1
<PackageReference Include="Magnitudo" Version="0.2.0-alpha.1" />
<PackageVersion Include="Magnitudo" Version="0.2.0-alpha.1" />
<PackageReference Include="Magnitudo" />
paket add Magnitudo --version 0.2.0-alpha.1
#r "nuget: Magnitudo, 0.2.0-alpha.1"
#:package Magnitudo@0.2.0-alpha.1
#addin nuget:?package=Magnitudo&version=0.2.0-alpha.1&prerelease
#tool nuget:?package=Magnitudo&version=0.2.0-alpha.1&prerelease
Magnitudo
Magnitudo is a .NET library for representing physical quantities, dimensions, and units, with dimensional consistency
checked at compile time. Quantities are described in a catalog file, a source generator turns each one into a
global using alias (Kelvin, Pascal, and so on), and an analyzer fails the build when an expression mixes
dimensions that don't fit, like adding a pressure to a temperature.
The aliases are erased. Kelvin is still a float in the compiled assembly, so there is no wrapper type, no runtime
cost, and nothing that gets in the way of Native AOT or trimming.
Magnitudo originated as the dimensional-analysis system used by the Numos atmospherics simulation library and was later separated into a general-purpose library.
Install
dotnet add package Magnitudo --prerelease
dotnet add package Magnitudo.Analyzers --prerelease
Magnitudo holds the [Quantity] and [ElementQuantity] attributes. Magnitudo.Analyzers is a development
dependency, so reference it with PrivateAssets="all" and it won't flow to your consumers:
<PackageReference Include="Magnitudo" Version="0.2.0-alpha.1"/>
<PackageReference Include="Magnitudo.Analyzers" Version="0.2.0-alpha.1" PrivateAssets="all"/>
Add a catalog
Put your quantities in a *.magnitudo file and include it as an AdditionalFiles item:
<ItemGroup>
<AdditionalFiles Include="MyProject.magnitudo"/>
</ItemGroup>
temperature | Kelvin | global::System.Single | temperature=1
pressure | Pascal | global::System.Single | mass=1,length=-1,time=-2
With that catalog, this fails to build:
static float Total(Pascal pressure, Kelvin temperature) => pressure + temperature;
// error QNT001: Operator '+' cannot combine 'length^-1 mass^1 time^-2' and 'temperature'
The docs, in reading order:
- Dimensional analysis: the model and what it costs at runtime.
- The catalog: the
.magnitudoformat, unit conversions, and catalog errors. - How the analyzer reasons: where quantities come from, what each position accepts, and what isn't checked.
- Diagnostics:
QNT000toQNT004, with failing examples and fixes. - Versioning and releasing.
Build, test, pack
dotnet build Magnitudo.slnx -c Release -warnaserror
dotnet test Magnitudo.slnx -c Release
dotnet pack Magnitudo.slnx -c Release
Packages land in artifacts/packages. Versions for both packages come from Version.props.
License
Magnitudo is licensed under the MIT license. See LICENSE.TXT for more info.
| 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
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.0-beta.1 | 231 | 10/25/2026 |
| 0.3.0-beta.4 | 119 | 10/23/2026 |
| 0.3.0-beta.3 | 66 | 10/23/2026 |
| 0.3.0-beta.2 | 72 | 10/22/2026 |
| 0.3.0-beta.1 | 60 | 10/22/2026 |
| 0.2.0-alpha.1 | 87 | 10/1/2026 |