Skip to content

Commit 87dc3c7

Browse files
authored
v4.0.0 (#487)
# 4.0.0 Release This PR will serve as the list of items to complete and it will be updated to show the progress before finally merged into `master` when completed. We all have busy schedules, so **if you want to help move this work forward then that is much appreciated!** ## The main theme is to reduce binary size In two years it has grown from 280 kB to 1.4 MB and a lot of it is due to unnecessary syntactic sugar with many method overloads for various number types and nullable types - for every of our 800+ units! It simply adds up to a big total. These items are chosen from #180, trying to include as many of the low hanging fruits as possible, while still keeping the list short and realistic to complete in a reasonably short time - we are all busy in our daily lives. We can always have more major version bumps later than trying to perfect it all now. ## Feature complete before November, merged before mid-December I would like to aim for a "beta" pre-release nuget sometime in October with all the items completed, so we can have some time to test it before releasing the final, stable 4.0.0 version before Christmas holidays. We should have the work items list more or less final before Monday, October 8th. ## Changes #### Added - [x] UnitSystem with a different meaning, now defines the base units for a unit system (#524) #### Removed - [x] Replace netstandard1.0 target with netstandard2.0, to avoid the extra dependencies (#477) - [x] Remove code marked as `[Obsolete]`, such as `VolumeUnit.Teaspoon` (#490) - [x] Remove nullable `From` factory methods (#483) - [x] Remove extension methods on _nullable_ number types (#483) - [x] Remove all number extension methods (#497) - [x] Remove `Length2d`, replaced by `Area` (#501) - [x] Remove static methods on `UnitSystem`, should use `UnitSystem.Default` instead (#496) - [x] Remove unit parameter from `ToString()` methods (#546) #### Changed - [x] Throw exception on NaN values in static constructor methods, like `FromMeters()` (#502, see #176 (comment)) - [x] Throw if unit was not specified when constructing quantities, (#499 - #389 (comment)) - [x] Stricter parsing (#343 and #180 (comment)) - [x] Remove unit parameter from `ToString()` methods (#546) - [x] Change Temperature arithmetic back to use base unit Kelvin (#550, see #518) #### Renamed - [x] Correct SingularName for some Flow unit definitions (#494, see #360) - [x] Split/rename UnitSystem into UnitParser, GlobalConfiguration, UnitAbbreviationsCache (#511) #### Fixed - [x] Search for any TODO comments in the code to address, remove comment and either fix or create issue (5d24432) - [x] Update README with v4 changes #498 - [x] Do not try/catch in UnitConverter.Try-methods (#506) - [x] Do not try/catch in `Length.TryParse()` and for other quantities (#507) - [x] Add/update changelog in wiki for v4 with some summary copied from this issue, some v3 to v4 migration instructions and briefly explain why some stuff were removed ## Milestones - [x] Finalize work items list (Monday, October 8) - [x] Release 4.0.0-beta1, feature complete (Wednesday, October 31) - [ ] ~Show release notes and upgrade guide when upgrading to 4.x nuget, if possible~ - [x] Release 4.0.0 (Monday, December 17)
1 parent 832301f commit 87dc3c7

File tree

854 files changed

+100549
-148641
lines changed

Some content is hidden

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

854 files changed

+100549
-148641
lines changed

.gitattributes

+2-20
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,9 @@
2020
*.filters text eol=crlf
2121
*.vcxitems text eol=crlf
2222

23-
24-
#*.sln merge=binary
25-
#*.csproj merge=binary
26-
#*.vbproj merge=binary
27-
#*.vcxproj merge=binary
28-
#*.vcproj merge=binary
29-
#*.dbproj merge=binary
30-
#*.fsproj merge=binary
31-
#*.lsproj merge=binary
32-
#*.wixproj merge=binary
33-
#*.modelproj merge=binary
34-
#*.sqlproj merge=binary
35-
#*.wwaproj merge=binary
36-
37-
#*.xproj merge=binary
38-
#*.props merge=binary
39-
#*.filters merge=binary
40-
#*.vcxitems merge=binary
41-
4223
# C#
43-
*.cs diff=csharp
24+
*.cs diff=csharp
25+
*.g.cs linguist-generated
4426

4527
# Powershell
4628
*.ps1 text eol=crlf

Build/Test.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$root = Resolve-Path $PSScriptRoot/..
2+
3+
[int]$exitCode = 0
4+
5+
# When this change is made available, we can possibly simplify below with: `dotnet test MySolution.sln`
6+
# Run tests only for test projects by smadala · Pull Request #1745 · Microsoft/vstest
7+
# https://github.com/Microsoft/vstest/pull/1745
8+
Get-ChildItem -Path $root -Recurse -Filter "*Tests*.csproj" | % {
9+
$projectFilePath = $_.FullName
10+
$projectName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
11+
$reportFilePath = [IO.Path]::GetFullPath("$root/TestResults/$projectName.xml")
12+
dotnet test $projectFilePath --logger "trx;LogFileName=$reportFilePath"
13+
if ($LASTEXITCODE) { $exitCode = $LASTEXITCODE }
14+
}
15+
16+
Write-Host -ForegroundColor Green "All tests run."
17+
exit $exitCode

Build/build-functions.psm1

+16-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ function Update-GeneratedCode {
2828

2929
function Start-Build([boolean] $skipUWP = $false) {
3030
write-host -foreground blue "Start-Build...`n---"
31-
dotnet build --configuration Release "$root\UnitsNet.sln"
31+
32+
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"
33+
34+
$appVeyorLoggerDll = "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
35+
$appVeyorLoggerNetCoreDll = "C:\Program Files\AppVeyor\BuildAgent\dotnetcore\Appveyor.MSBuildLogger.dll"
36+
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerNetCoreDll") { "/logger:$appVeyorLoggerNetCoreDll" } else { "" }
37+
38+
dotnet build --configuration Release "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
3239
if ($lastexitcode -ne 0) { exit 1 }
3340

3441
if ($skipUWP -eq $true)
@@ -37,11 +44,14 @@ function Start-Build([boolean] $skipUWP = $false) {
3744
}
3845
else
3946
{
47+
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.WindowsRuntimeComponent.msbuild.log"
48+
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }
49+
4050
# dontnet CLI does not support WindowsRuntimeComponent project type yet
4151
# msbuild does not auto-restore nugets for this project type
4252
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
4353
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release /t:restore
44-
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release
54+
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg
4555
if ($lastexitcode -ne 0) { exit 1 }
4656
}
4757

@@ -56,7 +66,7 @@ function Start-Tests {
5666
)
5767

5868
# Parent dir must exist before xunit tries to write files to it
59-
new-item -type directory $testReportDir 1> $null
69+
new-item -type directory -force $testReportDir 1> $null
6070

6171
write-host -foreground blue "Run tests...`n---"
6272
foreach ($projectPath in $projectPaths) {
@@ -68,7 +78,7 @@ function Start-Tests {
6878
# https://github.com/xunit/xunit/issues/1216
6979
push-location $projectDir
7080
# -nobuild <-- this gives an error, but might want to use this to avoid extra builds
71-
dotnet xunit -configuration Release -framework netcoreapp1.1 -xml $reportFile -nobuild
81+
dotnet xunit -configuration Release -framework netcoreapp2.0 -xml $reportFile -nobuild
7282
if ($lastexitcode -ne 0) { exit 1 }
7383
pop-location
7484
}
@@ -79,9 +89,7 @@ function Start-Tests {
7989
function Start-PackNugets {
8090
$projectPaths = @(
8191
"UnitsNet\UnitsNet.csproj",
82-
"UnitsNet\UnitsNet.Signed.csproj",
83-
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj",
84-
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Signed.csproj"
92+
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
8593
)
8694

8795
write-host -foreground blue "Pack nugets...`n---"
@@ -91,7 +99,7 @@ function Start-PackNugets {
9199
}
92100

93101
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
94-
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" -Symbols
102+
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
95103

96104
write-host -foreground blue "Pack nugets...END`n"
97105
}

Build/clean.bat

-4
This file was deleted.

Build/clean.ps1

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
# Don't allow using undeclared variables
2+
Set-Strictmode -version latest
3+
14
$root = "$PSScriptRoot\.."
2-
$artifactsDir = "$root\Artifacts"
3-
if (test-path $artifactsDir) {
4-
write-host -foreground blue "Delete Artifacts dir"
5-
rm -r -fo $artifactsDir -ErrorAction Continue
5+
Write-Host -Foreground Blue "Delete dirs: bin, obj"
6+
7+
[int]$deleteCount = 0
8+
[array]$failedToDeleteDirs = @()
9+
Get-ChildItem $root -Include bin,obj -Recurse -Force | %{
10+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $_.FullName
11+
if ($?) { $deleteCount++ }
12+
else {
13+
$failedToDeleteDirs += $_
14+
}
615
}
7-
write-host -foreground blue "Delete dirs: bin, obj"
8-
ls $root -inc bin,obj -r -fo | ri -r -fo -ErrorAction SilentlyContinue
16+
17+
Write-Host -Foreground Green "Deleted $deleteCount folders."
18+
19+
if ($failedToDeleteDirs) {
20+
$failCount = $failedToDeleteDirs.Count
21+
Write-Host ""
22+
Write-Host -Foreground Red "Failed to delete $failCount dirs:"
23+
$failedToDeleteDirs | %{
24+
Write-Host -Foreground Red $_.FullName
25+
}
26+
exit /B 1
27+
}

Build/set-version-UnitsNet.Serialization.JsonNet.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ Import-Module "$PSScriptRoot\set-version.psm1"
4848

4949
$root = Resolve-Path "$PSScriptRoot\.."
5050
$paramSet = $PsCmdlet.ParameterSetName
51-
$commonPropsFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Common.props"
52-
$versionFiles = @($commonPropsFile)
51+
$projFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
52+
$versionFiles = @($projFile)
5353
$projectName = "JsonNet"
5454

5555
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
56-
$newVersion = Get-NewProjectVersion $commonPropsFile $paramSet $setVersion $bumpVersion
56+
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
5757

58-
Set-ProjectVersion $commonPropsFile $newVersion
59-
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
58+
Set-ProjectVersion $projFile $newVersion
59+
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion

Build/set-version-UnitsNet.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ Import-Module "$PSScriptRoot\set-version.psm1"
5050

5151
$root = Resolve-Path "$PSScriptRoot\.."
5252
$paramSet = $PsCmdlet.ParameterSetName
53-
$commonPropsFile = "$root\UnitsNet\UnitsNet.Common.props"
53+
$projFile = "$root\UnitsNet\UnitsNet.csproj"
5454
$winrtAssemblyInfoFile = "$root\UnitsNet\Properties\AssemblyInfo.WindowsRuntimeComponent.cs"
5555
$winrtNuspecFile = "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec"
56-
$versionFiles = @($commonPropsFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
56+
$versionFiles = @($projFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
5757
$projectName = "UnitsNet"
5858

5959
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
60-
$newVersion = Get-NewProjectVersion $commonPropsFile $paramSet $setVersion $bumpVersion
60+
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
6161

62-
Set-ProjectVersion $commonPropsFile $newVersion
62+
Set-ProjectVersion $projFile $newVersion
6363
Set-AssemblyInfoVersion $winrtAssemblyInfoFile $newVersion
6464
Set-NuspecVersion $winrtNuspecFile $newVersion
6565
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion

Build/set-version.psm1

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ function Invoke-CommitAndTagVersion(
4343
}
4444

4545
function Set-ProjectVersion([string] $file, [string] $version) {
46-
Write-Host "$file -> $version"
46+
$assemblyVersion = $version -replace "(\d+)(?:\.\d+)+.*", '$1.0.0.0'
47+
Write-Host "$file -> $version (AssemblyVersion $assemblyVersion)"
4748
(Get-Content $file) -replace '<Version>.*?</Version>', "<Version>$version</Version>" | Set-Content $file
49+
(Get-Content $file) -replace '<AssemblyVersion>.*?</AssemblyVersion>', "<AssemblyVersion>$assemblyVersion</AssemblyVersion>" | Set-Content $file
4850
}
4951

5052
function Set-AssemblyInfoVersion([string] $file, [string] $version) {
53+
# Strip out any suffix: "4.0.0-alpha1" => "4.0.0"
54+
$version = $version.Split('-')[0]
5155
Write-Host "$file -> $version"
5256
(Get-Content $file) -replace 'Assembly(File)?Version\(".*?"\)', "Assembly`$1Version(`"$version`")" | Set-Content $file
5357
}
@@ -107,7 +111,7 @@ function BumpSuffix([string] $oldSuffix) {
107111
# Example:
108112
# -alpha => -alpha2
109113
# -alpha1 => -alpha2
110-
$match = [regex]::Match($oldSuffix, '^-(\w+)(\d+)?$');
114+
$match = [regex]::Match($oldSuffix, '^-([a-zA-Z]+)(\d+)?$');
111115
$oldSuffix = $match.Groups[1].Value
112116
$numberGroup = $match.Groups[2]
113117

@@ -150,4 +154,4 @@ function Resolve-Error ($ErrorRecord=$Error[0])
150154
}
151155
}
152156

153-
export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion
157+
export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion

0 commit comments

Comments
 (0)