Skip to content

Commit

Permalink
First release of Quantities (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
atmoos committed Nov 26, 2023
2 parents 01f8d26 + 38f7f22 commit 03ff338
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-quantities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
dotnet-version: ${{ env.DotNetVersion }}
- uses: tedd/publish-nuget-neo@v1
with:
NUGET_KEY: ${{secrets.CREATENEWNUGETPACKAGE}}
NUGET_KEY: ${{secrets.PUSH_NEW_QUANTITY_VERSION}}
PROJECT_FILE_PATH: ${{env.Project}}
TAG_COMMIT: true
TAG_FORMAT: ${{env.Prefix}}/v*
1 change: 1 addition & 0 deletions source/Quantities.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Build info common to all projects within the quantities project -->

<PropertyGroup>
<AssemblyName>Atmoos.$(RootNamespace)</AssemblyName>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
3 changes: 1 addition & 2 deletions source/Quantities.Pack.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<!-- Packaging info common to all projects within the quantities project -->

<PropertyGroup>
<Authors>Thomas Kägi</Authors>
<Copyright>Thomas Kägi</Copyright>
<Authors>Thomas Kägi, Radu Terec</Authors>
<PackageId>Atmoos.$(RootNamespace)</PackageId>
<PackageProjectUrl>https://github.com/atmoos/Quantities</PackageProjectUrl>
<RepositoryUrl>https://github.com/atmoos/Quantities</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
6 changes: 3 additions & 3 deletions source/Quantities/Globals.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
global using Quantities.Core;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("quantities.test")]
[assembly: InternalsVisibleTo("quantities.benchmark")]
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Atmoos.Quantities.Test")]
[assembly: InternalsVisibleTo("Atmoos.Quantities.Benchmark")]
2 changes: 1 addition & 1 deletion source/Quantities/Quantities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="../Quantities.Pack.targets"/>

<PropertyGroup>
<Version>0.1.0-alpha</Version>
<Version>1.0.0</Version>
<RootNamespace>Quantities</RootNamespace>
<Description>Type-safe and efficent handling of physical quantities.</Description>
</PropertyGroup>
Expand Down
71 changes: 53 additions & 18 deletions source/Quantities/readme.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,79 @@
# Atmoos Quantities

This library enables type-safe handling of quantities. It is a general purpose library that allows third parties to define their own units if needed. Many units are predefined in this library or are available on nuget.
This library enables type-safe handling of quantities. It is a general purpose library that allows third parties to define their own units if needed. Many units are predefined in this library or are available on nuget [here](https://www.nuget.org/packages/Atmoos.Quantities.Units/).

It's based on the international system of measurements (SI), but also supports many other units.
It is based on the [international system of units](https://en.wikipedia.org/wiki/International_System_of_Units) (SI), but also supports many other units, such as imperial units.

Design principles:

- Typesafe
- Type-safe by default.
- General purpose, i.e. extendable.
- Supports serialization.
- Broad set of units available in [Atmoos.Quantities.Units](https://www.nuget.org/packages/Atmoos.Quantities.Units/).
- Custom units are supported, too.
- All metric and binary prefixes are supported.
- Serialization is supported via *Atmoos.Quantities.Serialization*
- [System.Text.Json](https://www.nuget.org/packages/Atmoos.Quantities.Serialization.Text.Json/)
- [Newtonsoft](https://www.nuget.org/packages/Atmoos.Quantities.Serialization.Newtonsoft/)
- Optimized for
- speed
- likely faster than naive implementations.
- low memory footprint
- all quantities are structs and don't allocate on the heap.
- accuracy
- numerically more stable than just using doubles.
- **accuracy**: numerically more stable than just using doubles.
- **low memory footprint**: all quantities are structs and don't allocate on the heap.
- **speed**: likely faster than naive implementations.

## Usage Patterns

Add this global using somewhere in your project.

```csharp
global using static Quantities.Systems;
```

Then, quantities can be used like this:

```csharp
Time hours = Time.Of(4).Metric<Hour>();
Length feet = Length.Of(2).Imperial<Foot>();
Volume volume = Volume.Of(3).Cubic.Si<Metre>();
Length kilometres = Length.Of(16).Si<Kilo, Metre>();
Velocity kilometresPerHour = Velocity.Of(4).Si<Kilo, Metre>().Per.Metric<Hour>();
Time hours = Time.Of(4, Metric<Hour>());
Length feet = Length.Of(2, Imperial<Foot>());
Volume volume = Volume.Of(3, Cubic(Si<Metre>()));
Length kilometres = Length.Of(16, Si<Kilo, Metre>());
Velocity kilometresPerHour = Velocity.Of(4, Si<Kilo, Metre>().Per(Metric<Hour>()));
Velocity arithmeticVelocity = kilometres / hours; // 4 km/h
Area area = volume / feet; // 4.921... m²
```

## Supported Si Prefixes

- All metric prefixes `Quecto` through to `Quetta`.
- All binary prefixes `Kibi` through to `Yobi`.
- All [metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) `Quecto` through to `Quetta`.
- All [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) `Kibi` through to `Yobi`.

They are all compatible with each other.

## Supported Quantities

The currently supported quantities are:

```text
Quantities
├── Area
├── Data
├── DataRate
├── ElectricCurrent
├── ElectricPotential
├── ElectricalResistance
├── Energy
├── Force
├── Length
├── Mass
├── Power
├── Temperature
├── Time
├── Velocity
└── Volume
```

They support a broad range of compatible units as indicated by the examples above.

## Supported Units of Measurement

These are the units that are included in this library. Please see [Atmoos.Quantities.Units](https://www.nuget.org/packages/Atmoos.Quantities.Units/) for many more units.
The following units are included in this library. Please see [Atmoos.Quantities.Units](https://www.nuget.org/packages/Atmoos.Quantities.Units/) for many more units.

```text
├── Si
Expand Down

0 comments on commit 03ff338

Please sign in to comment.