UnitTools.Analyzers
1.0.2
dotnet add package UnitTools.Analyzers --version 1.0.2
NuGet\Install-Package UnitTools.Analyzers -Version 1.0.2
<PackageReference Include="UnitTools.Analyzers" Version="1.0.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="UnitTools.Analyzers" Version="1.0.2" />
<PackageReference Include="UnitTools.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add UnitTools.Analyzers --version 1.0.2
#r "nuget: UnitTools.Analyzers, 1.0.2"
#:package UnitTools.Analyzers@1.0.2
#addin nuget:?package=UnitTools.Analyzers&version=1.0.2
#tool nuget:?package=UnitTools.Analyzers&version=1.0.2
UnitTools
High-performance .NET unit conversions — straightforward numeric APIs, strongly typed quantities, and precise calculations.
GitHub repository · Documentation · Release notes
UnitTools includes 150 conversion families, 1,858 registered units, and 39,458 directed non-identity conversions within compatible families. Choose direct numeric conversion, fluent extensions, typed quantities, exact decimal/rational conversion, dynamic parsing, or custom unit definitions. The core library has no third-party runtime package dependencies.
Packages
| NuGet package | Purpose |
|---|---|
UnitTools |
Full conversion engine and quantity APIs |
UnitTools.SystemTextJson |
Optional System.Text.Json support for typed unit values |
UnitTools.Analyzers |
Optional Roslyn compile-time guidance |
All three packages ship with the same version, currently 1.0.2. Install only the parts you need.
Installation
dotnet add package UnitTools
For JSON integration or analyzer diagnostics, install the matching companion package in addition to the core package.
Quick start
using UnitTools;
using UnitTools.Length;
using UnitTools.Quantities;
// Numeric conversion: 4 km -> 4000 m.
double meters = UnitToolsLength.Convert(
4d,
UnitToolsLengthUnit.Kilometer,
UnitToolsLengthUnit.Meter);
// Fluent numeric conversion.
double fluentMeters = 4d.Convert(
UnitToolsLengthUnit.Kilometer,
UnitToolsLengthUnit.Meter);
// Keep the unit attached to a value.
double wrappedMeters = new UnitValue<UnitToolsLengthUnit>(
4d, UnitToolsLengthUnit.Kilometer)
.To(UnitToolsLengthUnit.Meter).Value;
// Compile-time dimensional safety.
Length<decimal> distance = Length<decimal>.FromKilometres(4m);
decimal typedMeters = distance.Metres;
Parsing, exact arithmetic, and composite units
double speed = UnitToolsDynamic.Convert("36 km/h", "m/s");
decimal exact = UnitToolsExact.Convert(
1m, UnitToolsLengthUnit.Inch, UnitToolsLengthUnit.Foot);
double energy = UnitToolsComposite.Convert(1d, "N*m", "J");
Compatibility and design
- Core: .NET Standard 2.0 and .NET 8.
- JSON and analyzer companions: .NET Standard 2.0.
- Standalone core without third-party runtime dependencies.
- Exact decimal/rational paths, span-based parsing/formatting, localization, composite units, and arbitrary-scale number naming.
- Release validation includes tests, API compatibility checks, NativeAOT smoke tests, and clean NuGet consumers.
Documentation and license
For complete APIs, sample programs, benchmarking, and supported families, visit the GitHub README.
License: Apache License 2.0 with Commons Clause v1.0. Redistribution is subject to the Commons Clause restriction on selling the software itself. Review the full license before redistribution.
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
|---|---|---|
| 1.0.2 | 92 | 10/13/2026 |
1.0.1: optional UC0002 guidance for compile-time-known dynamic conversions with conservative false-positive filtering across Convert/TryConvert and Roslyn release tracking.