SharpMeasures 0.3.70
dotnet add package SharpMeasures --version 0.3.70
NuGet\Install-Package SharpMeasures -Version 0.3.70
<PackageReference Include="SharpMeasures" Version="0.3.70" />
<PackageVersion Include="SharpMeasures" Version="0.3.70" />
<PackageReference Include="SharpMeasures" />
paket add SharpMeasures --version 0.3.70
#r "nuget: SharpMeasures, 0.3.70"
#:package SharpMeasures@0.3.70
#addin nuget:?package=SharpMeasures&version=0.3.70
#tool nuget:?package=SharpMeasures&version=0.3.70
SharpMeasures
SharpMeasures is an easily extended C# library that aims to encourage explicit usage of physical quantities and units of measurement during development. This is done by providing concrete types, such as Time, UnitOfLength, and Acceleration3 - together with a custom-built source generator. While SharpMeasures is mainly designed as a treatment for primitive obsession, common matematical operations are also implemented, allowing quantities to be derived from other quantities - as demonstrated below.
Displacement3 displacement = (0, 1.5, -4) * Distance.OneMetre;
Time time = 0.5 * Time.OneSecond;
Velocity3 velocity = displacement / time;
Console.WriteLine(velocity); // "(0, 3, -8) [m∙s⁻¹]"
Console.WriteLine(velocity.KilometresPerHour); // ~ "(0, 10.8, -28.8)"
See GitHub for more information.
Source Generator
The source generator used to implement SharpMeasures allows you to easily extend the existing set of quantities, or make new units and quantities from scratch:
using SharpMeasures.Generators;
[SpecializedScalarQuantity(typeof(Height))]
public partial class Altitude { }
This source generator can be found here.
Extensions
Soem additional, more situational, units and quantities can be found here:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net7.0
- SharpMeasures.Base (>= 0.3.69)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SharpMeasures:
| Package | Downloads |
|---|---|
|
SharpMeasures.Astronomy
Extends SharpMeasures with astronomy-related quantities. |
GitHub repositories
This package is not used by any popular GitHub repositories.