Skip to content

Commit f2963ae

Browse files
authored
Merge branch 'master' into master
2 parents edf2dfd + 425a947 commit f2963ae

File tree

169 files changed

+4254
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+4254
-419
lines changed

CodeGen/CodeGen.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
14-
<PackageReference Include="NuGet.Protocol" Version="6.2.2" />
14+
<PackageReference Include="NuGet.Protocol" Version="6.2.4" />
1515
<PackageReference Include="Serilog" Version="2.11.0" />
1616
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
1717
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.2.0-alpha.19174.3" />

CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public string Generate()
2525
<package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"">
2626
<metadata>
2727
<id>UnitsNet.nanoFramework.{_quantity.Name}</id>
28-
<version>5.16.0</version>
28+
<version>5.20.0</version>
2929
<title>Units.NET {_quantity.Name} - nanoFramework</title>
3030
<authors>Andreas Gullberg Larsen,nanoFramework project contributors</authors>
3131
<owners>UnitsNet</owners>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"Name": "AbsorbedDoseOfIonizingRadiation",
3+
"BaseUnit": "Gray",
4+
"XmlDocSummary": "Absorbed dose is a dose quantity which is the measure of the energy deposited in matter by ionizing radiation per unit mass.",
5+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Absorbed_dose",
6+
"BaseDimensions": {
7+
"L": 2,
8+
"T": -2
9+
},
10+
"Units": [
11+
{
12+
"SingularName": "Gray",
13+
"PluralName": "Grays",
14+
"BaseUnits": {
15+
"L": "Meter",
16+
"T": "Second"
17+
},
18+
"FromUnitToBaseFunc": "{x}",
19+
"FromBaseToUnitFunc": "{x}",
20+
"XmlDocSummary": "The gray is the unit of ionizing radiation dose in the SI, defined as the absorption of one joule of radiation energy per kilogram of matter.",
21+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Gray_(unit)",
22+
"Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Centi", "Kilo", "Mega", "Giga", "Tera", "Peta" ],
23+
"Localization": [
24+
{
25+
"Culture": "en-US",
26+
"Abbreviations": [ "Gy" ]
27+
},
28+
{
29+
"Culture": "ru-RU",
30+
"Abbreviations": [ "Гр" ]
31+
}
32+
]
33+
},
34+
{
35+
"SingularName": "Rad",
36+
"PluralName": "Rads",
37+
"FromUnitToBaseFunc": "{x} / 100",
38+
"FromBaseToUnitFunc": "{x} * 100",
39+
"XmlDocSummary": "The rad is a unit of absorbed radiation dose, defined as 1 rad = 0.01 Gy = 0.01 J/kg.",
40+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Rad_(radiation_unit)",
41+
"Prefixes": [ "Milli", "Kilo", "Mega" ],
42+
"Localization": [
43+
{
44+
"Culture": "en-US",
45+
"Abbreviations": [ "rad" ]
46+
},
47+
{
48+
"Culture": "ru-RU",
49+
"Abbreviations": [ "рад" ]
50+
}
51+
]
52+
}
53+
]
54+
}

Common/UnitDefinitions/Volume.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
}
7979
]
8080
},
81-
{
81+
{
8282
"SingularName": "CubicDecimeter",
8383
"PluralName": "CubicDecimeters",
8484
"FromUnitToBaseFunc": "{x} / 1e3",
@@ -461,6 +461,18 @@
461461
}
462462
]
463463
},
464+
{
465+
"SingularName": "ImperialQuart",
466+
"PluralName": "ImperialQuarts",
467+
"FromUnitToBaseFunc": "{x} * 1.1365225e-3",
468+
"FromBaseToUnitFunc": "{x} / 1.1365225e-3",
469+
"Localization": [
470+
{
471+
"Culture": "en-US",
472+
"Abbreviations": [ "qt (imp.)" ]
473+
}
474+
]
475+
},
464476
{
465477
"SingularName": "UsPint",
466478
"PluralName": "UsPints",

Common/UnitEnumValues.g.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,8 @@
15671567
"UsQuart": 50,
15681568
"UsTablespoon": 51,
15691569
"UsTeaspoon": 52,
1570-
"Nanoliter": 53
1570+
"Nanoliter": 53,
1571+
"ImperialQuart": 57
15711572
},
15721573
"VolumeConcentration": {
15731574
"CentilitersPerLiter": 1,
@@ -1755,5 +1756,23 @@
17551756
"PascalQubicMeterPerSecond": 1,
17561757
"TorrLiterPerSecond": 4,
17571758
"PascalCubicMeterPerSecond": 2
1759+
},
1760+
"AbsorbedDoseOfIonizingRadiation": {
1761+
"Centigray": 6,
1762+
"Femtogray": 7,
1763+
"Gigagray": 8,
1764+
"Gray": 5,
1765+
"Kilogray": 9,
1766+
"Kilorad": 4,
1767+
"Megagray": 3,
1768+
"Megarad": 2,
1769+
"Microgray": 1,
1770+
"Milligray": 10,
1771+
"Millirad": 18,
1772+
"Nanogray": 16,
1773+
"Petagray": 19,
1774+
"Picogray": 11,
1775+
"Rad": 17,
1776+
"Teragray": 14
17581777
}
17591778
}

README.md

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,23 @@ No more magic constants found on Stack Overflow, no more second-guessing the uni
1212

1313
### Overview
1414

15-
* [How to install](#how-to-install)
16-
* [100+ quantities with 1400+ units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [C# CLI app](CodeGen)
17-
* [30k unit tests](https://dev.azure.com/unitsnet/Units.NET/_build?definitionId=1)
18-
* [Statically typed quantities and units](#static-typing) to avoid mistakes and communicate intent
19-
* Immutable structs
20-
* [Operator overloads](#operator-overloads) for arithmetic
21-
* [Parse and ToString()](#culture) supports localization
22-
* [Dynamically parse and convert](#dynamic-parsing) quantities and units
23-
* [Extensible with custom units](#custom-units)
24-
* [Example: Creating a unit converter app](#example-app)
25-
* [Example: WPF app using IValueConverter to parse quantities from input](#example-wpf-app-using-ivalueconverter-to-parse-quantities-from-input)
26-
* [Precision and accuracy](#precision)
27-
* [Serialize to JSON, XML and more](#serialization)
28-
* [Contribute](#contribute) if you are missing some units
29-
* [Continuous integration](#ci) posts status reports to pull requests and commits
30-
* [Who are using this?](#who-are-using)
31-
32-
### <a name="how-to-install"></a>Installing via NuGet
15+
* [Overview](#overview)
16+
* [Installing via NuGet](#installing-via-nuget)
17+
* [Static Typing](#static-typing)
18+
* [Operator Overloads](#operator-overloads)
19+
* [Culture and Localization](#culture-and-localization)
20+
* [Dynamically Parse Quantities and Convert to Units](#dynamically-parse-quantities-and-convert-to-units)
21+
* [Custom units](#custom-units)
22+
* [Example: Unit converter app](#example-unit-converter-app)
23+
* [Example: WPF app using IValueConverter to parse input](#example-wpf-app-using-ivalueconverter-to-parse-input)
24+
* [Precision and Accuracy](#precision-and-accuracy)
25+
* [Serialize to JSON, XML and more](#serialize-to-json-xml-and-more)
26+
* [Want To Contribute?](#want-to-contribute)
27+
* [Continuous Integration](#continuous-integration)
28+
* [Who are Using This?](#who-are-using-this)
29+
* [Units.NET on other platforms](#unitsnet-on-other-platforms)
30+
31+
### Installing via NuGet
3332

3433
Add it via CLI
3534

@@ -43,7 +42,7 @@ or go to [NuGet Gallery | UnitsNet](https://www.nuget.org/packages/UnitsNet) for
4342
* .NET Standard 2.0
4443
* [.NET nanoFramework](https://www.nanoframework.net/)
4544

46-
### <a name="static-typing"></a>Static Typing
45+
### Static Typing
4746

4847
```C#
4948
// Construct
@@ -67,7 +66,7 @@ string PrintPersonWeight(Mass weight)
6766
}
6867
```
6968

70-
### <a name="operator-overloads"></a>Operator Overloads
69+
### Operator Overloads
7170

7271
```C#
7372
// Arithmetic
@@ -82,7 +81,7 @@ Acceleration a2 = Force.FromNewtons(100) / Mass.FromKilograms(20);
8281
RotationalSpeed r = Angle.FromDegrees(90) / TimeSpan.FromSeconds(2);
8382
```
8483

85-
### <a name="culture"></a>Culture and Localization
84+
### Culture and Localization
8685

8786
The culture for abbreviations defaults to Thread.CurrentCulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are:
8887

@@ -122,7 +121,7 @@ Unfortunately there is no built-in way to avoid this, either you need to ensure
122121
Example:
123122
`Length.Parse("1 pt")` throws `AmbiguousUnitParseException` with message `Cannot parse "pt" since it could be either of these: DtpPoint, PrinterPoint`.
124123

125-
### <a name="dynamic-parsing"></a>Dynamically Parse Quantities and Convert to Units
124+
### Dynamically Parse Quantities and Convert to Units
126125
Sometimes you need to work with quantities and units at runtime, such as parsing user input.
127126

128127
There are a handful of classes to help with this:
@@ -169,6 +168,16 @@ if (Quantity.TryFrom(3, LengthUnit.Centimeter, out IQuantity quantity2))
169168
{
170169
}
171170
```
171+
172+
You can also construct from strings, such as mapping between DTO types in an API:
173+
```c#
174+
IQuantity quantity = Quantity.From(value: 3, quantityName: "Length", unitName: "Centimeter");
175+
176+
if (Quantity.TryFrom(value: 3, quantityName: "Length", unitName: "Centimeter", out IQuantity? quantity2))
177+
{
178+
}
179+
```
180+
172181
#### Parse quantity
173182
Parse any string to a quantity instance of the given the quantity type.
174183

@@ -222,7 +231,7 @@ UnitConverter.ConvertByName(1, "Length", "Centimeter", "Millimeter"); // 10 mm
222231
UnitConverter.ConvertByAbbreviation(1, "Length", "cm", "mm"); // 10 mm
223232
```
224233

225-
### <a name="custom-units"></a>Custom units
234+
### Custom units
226235

227236
Units.NET allows you to add your own units and quantities at runtime, to represent as `IQuantity` and reusing Units.NET for parsing and converting between units.
228237

@@ -252,7 +261,7 @@ Console.WriteLine(Convert(HowMuchUnit.Lots)); // 100 lts
252261
Console.WriteLine(Convert(HowMuchUnit.Tons)); // 10 tns
253262
```
254263

255-
### <a name="example-app"></a>Example: Unit converter app
264+
### Example: Unit converter app
256265
[Source code](https://github.com/angularsen/UnitsNet/tree/master/Samples/UnitConverter.Wpf) for `Samples/UnitConverter.Wpf`<br/>
257266
[Download](https://github.com/angularsen/UnitsNet/releases/tag/UnitConverterWpf%2F2018-11-09) (release 2018-11-09 for Windows)
258267
@@ -291,15 +300,15 @@ double convertedValue = UnitConverter.Convert(
291300
SelectedToUnit.UnitEnumValue); // Enum, such as LengthUnit.Centimeter
292301
```
293302

294-
### Example: WPF app using IValueConverter to parse quantities from input
303+
### Example: WPF app using IValueConverter to parse input
295304

296305
Src: [Samples/WpfMVVMSample](https://github.com/angularsen/UnitsNet/tree/master/Samples/WpfMVVMSample)
297306
298307
![wpfmvvmsample_219w](https://user-images.githubusercontent.com/787816/34913417-094332e2-f8fd-11e7-9d8a-92db105fbbc9.png)
299308
300309
The purpose of this app is to show how to create an `IValueConverter` in order to bind XAML to quantities.
301310

302-
### <a name="precision"></a>Precision and Accuracy
311+
### Precision and Accuracy
303312

304313
A base unit is chosen for each unit class, represented by a double value (64-bit), and all conversions go via this unit. This means that there will always be a small error in both representing other units than the base unit as well as converting between units.
305314

@@ -309,28 +318,24 @@ The tests accept an error up to 1E-5 for most units added so far. Exceptions inc
309318

310319
For more details, see [Precision](https://github.com/angularsen/UnitsNet/wiki/Precision).
311320
312-
### <a name="serialization"></a>Serialize to JSON, XML and more
313-
314-
* [UnitsNet.Serialization.JsonNet](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet) with Json.NET (Newtonsoft)
315-
* [DataContractSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datacontractserializer) XML
316-
* [DataContractJsonSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.json.datacontractjsonserializer) JSON (not recommended*)
321+
### Serialize to JSON, XML and more
317322

318-
Read more at [Serializing to JSON, XML and more](https://github.com/angularsen/UnitsNet/wiki/Serializing-to-JSON,-XML-and-more).
323+
Read the wiki on [Serializing to JSON, XML and more](https://github.com/angularsen/UnitsNet/wiki/Serializing-to-JSON,-XML-and-more).
319324
320325

321-
### <a name="contribute"></a>Want To Contribute?
326+
### Want To Contribute?
322327

323328
- [Adding a New Unit](https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit) is fairly easy to do and we are happy to help.
324329
- Want a new feature or to report a bug? [Create an issue](https://github.com/angularsen/UnitsNet/issues/new/choose) or start a [discussion](https://github.com/angularsen/UnitsNet/discussions).
325330
326-
### <a name="ci"></a>Continuous Integration
331+
### Continuous Integration
327332

328333
[AppVeyor](https://ci.appveyor.com/project/angularsen/unitsnet) performs the following:
329334
* Build and test all branches
330335
* Build and test pull requests, notifies on success or error
331336
* Deploy nugets on master branch, if nuspec versions changed
332337

333-
### <a name="who-are-using"></a>Who are Using This?
338+
### Who are Using This?
334339

335340
It would be awesome to know who are using this library. If you would like your project listed here, [create an issue](https://github.com/angularsen/UnitsNet/issues) or edit the [README.md](https://github.com/angularsen/UnitsNet/edit/master/README.md) and send a pull request. Max logo size is `300x35 pixels` and should be in `.png`, `.gif` or `.jpg` formats.
336341
@@ -411,7 +416,7 @@ https://github.com/StructuralAnalysisFormat/StructuralAnalysisFormat-SDK
411416
412417
*- Dirk Schuermans, Software Engineer for [SCIA nv](https://www.scia.net)*
413418
414-
## Units.NET on other platforms
419+
### Units.NET on other platforms
415420

416421
Get the same strongly typed units on other platforms, based on the same [unit definitions](/Common/UnitDefinitions).
417422

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
5+
</PropertyGroup>
6+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<ProjectGuid>{3d39134e-c97d-cba4-a559-fdb3a0da5e54}</ProjectGuid>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileAlignment>512</FileAlignment>
15+
<RootNamespace>UnitsNet</RootNamespace>
16+
<AssemblyName>UnitsNet.AbsorbedDoseOfIonizingRadiation</AssemblyName>
17+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
18+
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
19+
</PropertyGroup>
20+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
21+
<ItemGroup>
22+
<Compile Include="..\Quantities\AbsorbedDoseOfIonizingRadiation.g.cs" />
23+
<Compile Include="..\Units\AbsorbedDoseOfIonizingRadiationUnit.g.cs" />
24+
<Compile Include="..\Properties\AssemblyInfo.cs" />
25+
</ItemGroup>
26+
<ItemGroup>
27+
<Reference Include="mscorlib, Version=1.14.3.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
28+
<HintPath>..\packages\nanoFramework.CoreLibrary.1.14.2\lib\mscorlib.dll</HintPath>
29+
<Private>True</Private>
30+
<SpecificVersion>True</SpecificVersion>
31+
</Reference>
32+
</ItemGroup>
33+
<ItemGroup>
34+
<None Include="packages.config" />
35+
</ItemGroup>
36+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
37+
<ProjectExtensions>
38+
<ProjectCapabilities>
39+
<ProjectConfigurationsDeclaredAsItems />
40+
</ProjectCapabilities>
41+
</ProjectExtensions>
42+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
3+
<metadata>
4+
<id>UnitsNet.nanoFramework.AbsorbedDoseOfIonizingRadiation</id>
5+
<version>5.20.0</version>
6+
<title>Units.NET AbsorbedDoseOfIonizingRadiation - nanoFramework</title>
7+
<authors>Andreas Gullberg Larsen,nanoFramework project contributors</authors>
8+
<owners>UnitsNet</owners>
9+
<license type="expression">MIT</license>
10+
<projectUrl>https://github.com/angularsen/UnitsNet</projectUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>Adds AbsorbedDoseOfIonizingRadiation units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead.</description>
13+
<iconUrl>https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png</iconUrl>
14+
<releaseNotes>
15+
</releaseNotes>
16+
<copyright>Copyright 2013 Andreas Gullberg Larsen ([email protected]).</copyright>
17+
<language>en-US</language>
18+
<tags>nanoframework absorbeddoseofionizingradiation unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable</tags>
19+
<dependencies>
20+
<dependency id="nanoFramework.CoreLibrary" version="1.14.2" />
21+
</dependencies>
22+
</metadata>
23+
<files>
24+
<file src="..\..\..\Artifacts\UnitsNet.NanoFramework\AbsorbedDoseOfIonizingRadiation\UnitsNet.*" target="lib" />
25+
</files>
26+
</package>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.14.2" targetFramework="netnanoframework10" />
4+
</packages>

UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>UnitsNet.nanoFramework.Acceleration</id>
5-
<version>5.16.0</version>
5+
<version>5.20.0</version>
66
<title>Units.NET Acceleration - nanoFramework</title>
77
<authors>Andreas Gullberg Larsen,nanoFramework project contributors</authors>
88
<owners>UnitsNet</owners>

0 commit comments

Comments
 (0)