Skip to content

Commit 9574d47

Browse files
authored
v5 Release (#982)
Fixes #180 Merging the v5 release branch. It is still in alpha, but it is functional, nugets are published and there are not many planned breaking changes left. By merging, all efforts moving forward are targeting v5 and this reduces friction: - No more merge conflicts trying to forward port all changes to v5, instead cherry pick new units and fixes to v4 until v5 is fully stable. - Contributors are having trouble building v4 locally due to `net40`, `net47` and Windows Runtime Component targets. ## 💥 Breaking changes Default number format should be CultureInfo.CurrentCulture, not CurrentUICulture (#795) Use CurrentCulture rather than CurrentUICulture (#986) Return `QuantityValue` in `IQuantity` properties instead of `double` (#1074) Return `decimal` in properties of `Power`, `BitRate` and `Information` quantities (#1074) Fix singular name VolumeFlow.MillionUsGallonsPerDay ## 🔥 Removed Remove targets: net40, net47, Windows Runtime Component. Remove `Undefined` enum value for all unit enum types Remove QuantityType enum Remove IQuantity.Units and .UnitNames Remove IQuantity.ToString() overloads Remove IEquatable<T> and equality operators/methods Remove GlobalConfiguration Remove obsolete and deprecated code. Remove Molarity ctor and operator overloads Remove MinValue, MaxValue per quantity due to ambiguity Remove string format specifiers: "v", "s" json: Remove UnitsNetJsonConverter ## ✨ New QuantityValue: Implement IEquality, IComparable, IFormattable QuantityValue: 16 bytes instead of 40 bytes (#1084) Add `[DataContract]` annotations (#972) ## ♻️ Improvements Upgrade CodeGen, tests and sample apps to net6.0. ## 📝 JSON unit definition schema changes Rename `BaseType` to `ValueType`, for values "double" and "decimal". Rename `XmlDoc` to `XmlDocSummary`. ## TODO Add back `IEquatable<T>`, but implement as strict equality with tuple of quantity name + unit + value. #1017 (comment) ## Postponed for later #1067
1 parent 7519a21 commit 9574d47

File tree

1,290 files changed

+15803
-238136
lines changed

Some content is hidden

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

1,290 files changed

+15803
-238136
lines changed

Diff for: Build/build-functions.psm1

+3-30
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Update-GeneratedCode {
2828
write-host -foreground blue "Generate code...END`n"
2929
}
3030

31-
function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false, [boolean] $IncludeNanoFramework = $false) {
31+
function Start-Build([boolean] $IncludeNanoFramework = $false) {
3232
write-host -foreground blue "Start-Build...`n---"
3333

3434
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"
@@ -40,24 +40,6 @@ function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false, [boolea
4040
dotnet build --configuration Release "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
4141
if ($lastexitcode -ne 0) { exit 1 }
4242

43-
if (-not $IncludeWindowsRuntimeComponent)
44-
{
45-
write-host -foreground yellow "Skipping WindowsRuntimeComponent build."
46-
}
47-
else
48-
{
49-
write-host -foreground green "Build WindowsRuntimeComponent."
50-
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.WindowsRuntimeComponent.msbuild.log"
51-
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }
52-
53-
# dontnet CLI does not support WindowsRuntimeComponent project type yet
54-
# msbuild does not auto-restore nugets for this project type
55-
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
56-
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release /t:restore
57-
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg
58-
if ($lastexitcode -ne 0) { exit 1 }
59-
}
60-
6143
if (-not $IncludeNanoFramework)
6244
{
6345
write-host -foreground yellow "Skipping .NET nanoFramework build."
@@ -82,8 +64,7 @@ function Start-Tests {
8264
$projectPaths = @(
8365
"UnitsNet.Tests\UnitsNet.Tests.csproj",
8466
"UnitsNet.NumberExtensions.Tests\UnitsNet.NumberExtensions.Tests.csproj",
85-
"UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.csproj",
86-
"UnitsNet.Serialization.JsonNet.CompatibilityTests\UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj"
67+
"UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.csproj"
8768
)
8869

8970
# Parent dir must exist before xunit tries to write files to it
@@ -129,21 +110,13 @@ function Start-PackNugets {
129110
if ($lastexitcode -ne 0) { exit 1 }
130111
}
131112

132-
if (-not $IncludeWindowsRuntimeComponent) {
133-
write-host -foreground yellow "Skipping WindowsRuntimeComponent nuget pack."
134-
} else {
135-
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
136-
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
137-
}
138-
139113
if (-not $IncludeNanoFramework) {
140114
write-host -foreground yellow "Skipping nanoFramework nuget pack."
141115
} else {
142116
write-host -foreground yellow "nanoFramework project not yet supported by dotnet CLI, using nuget.exe instead"
143-
Invoke-Build-NanoNugets
117+
Invoke-BuildNanoNugets
144118
}
145119

146-
147120
write-host -foreground blue "Pack nugets...END`n"
148121
}
149122

Diff for: Build/build-pack-nano-nugets.psm1

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$nugetOutDir = "$root\Artifacts\NuGet"
33
$nuget = "$root\Tools\NuGet.exe"
44

5-
function Invoke-Build-NanoNugets {
5+
function Invoke-BuildNanoNugets {
66

77
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Duration\UnitsNet.NanoFramework.Duration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
88
& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricCurrent\UnitsNet.NanoFramework.ElectricCurrent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
@@ -25,4 +25,4 @@ function Invoke-Build-NanoNugets {
2525

2626
}
2727

28-
export-modulemember -function Invoke-Build-NanoNugets
28+
export-modulemember -function Invoke-BuildNanoNugets

Diff for: Build/build.ps1

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@
77
88
Publishing nugets is handled by nuget-publish.bat and run by the build server
99
on the master branch.
10-
.PARAMETER skipUWP
11-
If flag is set, will skip the UWP (Windows Runtime Component) build step as this requires
12-
some large, extra Visual Studio features to be installed.
1310
.EXAMPLE
1411
powershell ./build.ps1
15-
powershell ./build.ps1 -IncludeWindowsRuntimeComponent -IncludeNanoFramework
12+
powershell ./build.ps1 -IncludeNanoFramework
1613
1714
.NOTES
1815
Author: Andreas Gullberg Larsen
1916
Last modified: Jan 21, 2018
2017
#>
2118
[CmdletBinding()]
2219
Param(
23-
[switch] $IncludeWindowsRuntimeComponent,
2420
[switch] $IncludeNanoFramework
2521
)
2622

@@ -32,7 +28,7 @@ try {
3228

3329
Remove-ArtifactsDir
3430
Update-GeneratedCode
35-
Start-Build -IncludeWindowsRuntimeComponent $IncludeWindowsRuntimeComponent -IncludeNanoFramework $IncludeNanoFramework
31+
Start-Build -IncludeNanoFramework $IncludeNanoFramework
3632
Start-Tests
3733
Start-PackNugets
3834
Compress-ArtifactsAsZip

Diff for: Build/init.ps1

+10-5
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,24 @@ if (!(Test-Path "$msbuildPath/nanoFramework")) {
6868
$extensionVersion = $vs2019Tag
6969
}
7070

71-
Write-Output "Downloading visx..." -NoNewline
71+
Write-Output "Downloading visx..."
7272

7373
# download VS extension
74-
Write-Debug "Download VSIX file from $extensionUrl to $vsixPath"
74+
Write-Host "Download VSIX file from $extensionUrl to $vsixPath"
7575
$webClient.DownloadFile($extensionUrl, $vsixPath)
7676

7777
$outputPath = "$tempDir\nf-extension"
7878

7979
$vsixPath = Join-Path -Path $tempDir -ChildPath "nf-extension.zip"
80-
$webClient.DownloadFile($extensionUrl,$vsixPath)
81-
Expand-Archive -LiteralPath $vsixPath -DestinationPath $outputPath | Write-Host
80+
$webClient.DownloadFile($extensionUrl, $vsixPath)
81+
82+
Write-Host "Extract VSIX file to $outputPath"
83+
Expand-Archive -LiteralPath $vsixPath -DestinationPath $outputPath -Force | Write-Host
84+
85+
$copyFrom = "$outputPath\`$MSBuild\nanoFramework"
8286

83-
Copy-Item -Path "$outputPath\`$MSBuild\nanoFramework" -Destination $msbuildPath -Recurse
87+
Write-Host "Copy from $copyFrom to $msbuildPath"
88+
Copy-Item -Path "$copyFrom" -Destination $msbuildPath -Recurse
8489

8590
Write-Host "Installed VS extension $extensionVersion"
8691
}

Diff for: Build/set-version-UnitsNet.ps1

-8
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ $projFile = "$root\UnitsNet\UnitsNet.csproj"
5555
$numberExtensionsProjFile = "$root\UnitsNet.NumberExtensions\UnitsNet.NumberExtensions.csproj"
5656
$nanoFrameworkNuspecGeneratorFile = "$root\CodeGen\Generators\NanoFrameworkGen\NuspecGenerator.cs"
5757
$nanoFrameworkAssemblyInfoFile = "$root\UnitsNet.NanoFramework\GeneratedCode\Properties\AssemblyInfo.cs"
58-
$winrtAssemblyInfoFile = "$root\UnitsNet.WindowsRuntimeComponent\Properties\AssemblyInfo.cs"
59-
$winrtNuspecFile = "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec"
6058

6159
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
6260
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
@@ -68,15 +66,9 @@ $didStash = Invoke-StashPush
6866
Set-ProjectVersion $projFile $newVersion
6967
Set-ProjectVersion $numberExtensionsProjFile $newVersion
7068

71-
# Update AssemblyInfo.cs files
72-
Set-AssemblyInfoVersion $winrtAssemblyInfoFile $newVersion
73-
7469
# Update AssemblyInfo.cs file for .NET nanoFramework
7570
Set-AssemblyInfoVersion $nanoFrameworkAssemblyInfoFile $newVersion
7671

77-
# Update .nuspec files
78-
Set-NuspecVersion $winrtNuspecFile $newVersion
79-
8072
# Update codegen and .nuspec files for nanoFramework
8173
Set-NuspecVersion $nanoFrameworkNuspecGeneratorFile $newVersion
8274
Get-ChildItem -Path "$root\UnitsNet.NanoFramework\GeneratedCode" -Include '*.nuspec' -Recurse |

Diff for: Build/set-version-json.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# Sets version of nuget UnitNets.Serialization.JsonNet.
3+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
set_version_script="$script_dir/set-version-UnitsNet.Serialization.JsonNet.ps1"
5+
6+
if [ $# -eq 1 ]; then
7+
powershell -NoProfile $set_version_script -setVersion $1
8+
exit 0
9+
else
10+
echo "Usage: ./set-version-json.sh <version>"
11+
echo ""
12+
echo "Examples:"
13+
echo "$ ./set-version-json.sh 5.0.0-alpha001"
14+
echo "$ ./set-version-json.sh 5.1.2"
15+
exit 1
16+
fi

Diff for: CodeGen/CodeGen.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp5.0</TargetFramework>
5+
<TargetFramework>netcoreapp6.0</TargetFramework>
66
<LangVersion>latest</LangVersion>
77
<Nullable>enable</Nullable>
88
<!-- Allow compile with various nullability warnings until fixed. -->

Diff for: CodeGen/Generators/GeneratorBase.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ namespace CodeGen.Generators
77
{
88
internal abstract class GeneratorBase
99
{
10-
protected readonly MyTextWriter Writer = new MyTextWriter();
11-
public abstract string Generate();
10+
protected readonly MyTextWriter Writer = new();
1211

13-
public const string GeneratedFileHeader = @"//------------------------------------------------------------------------------
12+
protected const string GeneratedFileHeader = @"//------------------------------------------------------------------------------
1413
// <auto-generated>
1514
// This code was generated by \generate-code.bat.
1615
//

Diff for: CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public NuspecGenerator(
1919
_mathNuGetVersion = mathNuGetVersion;
2020
}
2121

22-
public override string Generate()
22+
public string Generate()
2323
{
2424
Writer.WL($@"<?xml version=""1.0"" encoding=""utf-8""?>
2525
<package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"">
2626
<metadata>
2727
<id>UnitsNet.nanoFramework.{_quantity.Name}</id>
28-
<version>4.149.0</version>
28+
<version>5.0.0-alpha006</version>
2929
<title>Units.NET {_quantity.Name} - nanoFramework</title>
3030
<authors>Andreas Gullberg Larsen,nanoFramework project contributors</authors>
3131
<owners>UnitsNet</owners>
@@ -38,7 +38,7 @@ public override string Generate()
3838
</releaseNotes>
3939
<copyright>Copyright 2013 Andreas Gullberg Larsen ([email protected]).</copyright>
4040
<language>en-US</language>
41-
<tags>nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component {_quantity.Name.ToLower()}</tags>
41+
<tags>nanoframework {_quantity.Name.ToLower()} unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable</tags>
4242
<dependencies>
4343
<dependency id=""nanoFramework.CoreLibrary"" version=""{_mscorlibNuGetVersion}"" />");
4444

Diff for: CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public ProjectGenerator(Quantity quantity, NanoFrameworkVersions versions)
1414
_versions = versions;
1515
}
1616

17-
public override string Generate()
17+
public string Generate()
1818
{
1919
Writer.WL($@"<?xml version=""1.0"" encoding=""utf-8""?>
2020
<Project ToolsVersion=""15.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">

Diff for: CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public PropertyGenerator(string version)
1313
_version = version;
1414
}
1515

16-
public override string Generate()
16+
public string Generate()
1717
{
1818
Writer.WL(GeneratedFileHeader);
1919
Writer.W($@"using System.Reflection;

0 commit comments

Comments
 (0)