Magnitudo 0.2.0-alpha.1

This is a prerelease version of Magnitudo.
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Magnitudo" Version="0.2.0-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Magnitudo" Version="0.2.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="Magnitudo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Magnitudo --version 0.2.0-alpha.1
                    
#r "nuget: Magnitudo, 0.2.0-alpha.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Magnitudo@0.2.0-alpha.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Magnitudo&version=0.2.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Magnitudo&version=0.2.0-alpha.1&prerelease
                    
Install as a Cake Tool

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:

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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