Skip to content

Commit 7fe9a0b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into master-anjdreas
2 parents f0a26ba + 38e034b commit 7fe9a0b

File tree

921 files changed

+154932
-200756
lines changed

Some content is hidden

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

921 files changed

+154932
-200756
lines changed

.editorconfig

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# EditorConfig is awesome:http://EditorConfig.org
2+
# Based on: https://raw.githubusercontent.com/dotnet/roslyn/master/.editorconfig
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Don't use tabs for indentation.
8+
[*]
9+
indent_style = space
10+
trim_trailing_whitespace = true
11+
trim_trailing_white_space_on_save = true
12+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
13+
14+
# Code files
15+
[*.{cs,csx,vb,vbx}]
16+
indent_size = 4
17+
insert_final_newline = true
18+
charset = utf-8-bom
19+
20+
[*.{cmd,bat}]
21+
indent_size = 2
22+
end_of_line = crlf
23+
insert_final_newline = false
24+
25+
[*.{ps1,psm1}]
26+
indent_size = 2
27+
end_of_line = crlf
28+
insert_final_newline = true
29+
charset = utf-8-bom
30+
31+
# Xml project files
32+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
33+
indent_size = 2
34+
35+
# Xml config files
36+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
37+
indent_size = 2
38+
39+
# JSON files
40+
[*.json]
41+
indent_size = 2
42+
43+
# Dotnet code style settings:
44+
[*.{cs,vb}]
45+
# Sort using and Import directives with System.* appearing first
46+
dotnet_sort_system_directives_first = true
47+
# Avoid "this." and "Me." if not necessary
48+
dotnet_style_qualification_for_field = false:suggestion
49+
dotnet_style_qualification_for_property = false:suggestion
50+
dotnet_style_qualification_for_method = false:suggestion
51+
dotnet_style_qualification_for_event = false:suggestion
52+
53+
# Use language keywords instead of framework type names for type references
54+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
55+
dotnet_style_predefined_type_for_member_access = true:suggestion
56+
57+
# Suggest more modern language features when available
58+
dotnet_style_object_initializer = true:suggestion
59+
dotnet_style_collection_initializer = true:suggestion
60+
dotnet_style_coalesce_expression = true:suggestion
61+
dotnet_style_null_propagation = true:suggestion
62+
dotnet_style_explicit_tuple_names = true:suggestion
63+
64+
# CSharp code style settings:
65+
[*.cs]
66+
# Prefer "var" everywhere
67+
csharp_style_var_for_built_in_types = true:suggestion
68+
csharp_style_var_when_type_is_apparent = true:suggestion
69+
csharp_style_var_elsewhere = true:suggestion
70+
71+
# Prefer method-like constructs to have a block body
72+
csharp_style_expression_bodied_methods = false:none
73+
csharp_style_expression_bodied_constructors = false:none
74+
csharp_style_expression_bodied_operators = false:none
75+
76+
# Prefer property-like constructs to have an expression-body
77+
csharp_style_expression_bodied_properties = true:none
78+
csharp_style_expression_bodied_indexers = true:none
79+
csharp_style_expression_bodied_accessors = true:none
80+
81+
# Suggest more modern language features when available
82+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
83+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
84+
csharp_style_inlined_variable_declaration = true:suggestion
85+
csharp_style_throw_expression = true:suggestion
86+
csharp_style_conditional_delegate_call = true:suggestion
87+
88+
# Newline settings
89+
csharp_new_line_before_open_brace = all
90+
csharp_new_line_before_else = true
91+
csharp_new_line_before_catch = true
92+
csharp_new_line_before_finally = true
93+
csharp_new_line_before_members_in_object_initializers = true
94+
csharp_new_line_before_members_in_anonymous_types = true

.gitattributes

Lines changed: 2 additions & 20 deletions
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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ bld/
2222
[Oo]bj/
2323
[Ll]og/
2424

25+
# VS Code dir
26+
.vscode/
27+
2528
# Visual Studio 2015 cache/options directory
2629
.vs/
2730
# Uncomment if you have tasks that create the project's static files in wwwroot

Build/Test.ps1

Lines changed: 17 additions & 0 deletions
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

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
$root = "$PSScriptRoot\.."
1+
$root = "$PSScriptRoot\.."
22
$artifactsDir = "$root\Artifacts"
33
$nugetOutDir = "$root\Artifacts\NuGet"
44
$testReportDir = "$root\Artifacts\Logs"
55
$nuget = "$root\Tools\NuGet.exe"
6-
7-
function Start-NugetRestore {
8-
write-host -foreground blue "Restore nugets...`n"
9-
dotnet restore "$root\UnitsNet.sln"
10-
11-
# This project type is not supported by dotnet CLI yet
12-
& $nuget restore "$root\UnitsNet.WindowsRuntimeComponent.sln"
13-
write-host -foreground blue "Restore nugets...END`n"
6+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
7+
$msbuild = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
8+
if ($msbuild) {
9+
$msbuild = join-path $msbuild 'MSBuild\15.0\Bin\MSBuild.exe'
1410
}
1511

1612
function Remove-ArtifactsDir {
@@ -30,28 +26,47 @@ function Update-GeneratedCode {
3026
write-host -foreground blue "Generate code...END`n"
3127
}
3228

33-
function Start-Build {
29+
function Start-Build([boolean] $skipUWP = $false) {
3430
write-host -foreground blue "Start-Build...`n---"
35-
dotnet build --configuration Release "$root\UnitsNet.sln"
36-
if ($lastexitcode -ne 0) { exit 1 }
3731

38-
# dontnet CLI does not support WindowsRuntimeComponent project type yet
39-
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
40-
& msbuild "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release
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
4139
if ($lastexitcode -ne 0) { exit 1 }
4240

41+
if ($skipUWP -eq $true)
42+
{
43+
write-host -foreground yellow "Skipping WindowsRuntimeComponent build by user-specified flag."
44+
}
45+
else
46+
{
47+
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.WindowsRuntimeComponent.msbuild.log"
48+
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }
49+
50+
# dontnet CLI does not support WindowsRuntimeComponent project type yet
51+
# msbuild does not auto-restore nugets for this project type
52+
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
53+
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release /t:restore
54+
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg
55+
if ($lastexitcode -ne 0) { exit 1 }
56+
}
57+
4358
write-host -foreground blue "Start-Build...END`n"
4459
}
4560

4661
function Start-Tests {
4762
$projectPaths = @(
4863
"UnitsNet.Tests\UnitsNet.Tests.NetCore.csproj",
49-
"UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.NetCore.csproj"
50-
"UnitsNet.Tests.WindowsRuntimeComponent\UnitsNet.Tests.WindowsRuntimeComponent.csproj"
64+
"UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.NetCore.csproj",
65+
"UnitsNet.Serialization.JsonNet.CompatibilityTests\UnitsNet.Serialization.JsonNet.CompatibilityTests.NetCore.csproj"
5166
)
5267

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

5671
write-host -foreground blue "Run tests...`n---"
5772
foreach ($projectPath in $projectPaths) {
@@ -63,7 +78,7 @@ function Start-Tests {
6378
# https://github.com/xunit/xunit/issues/1216
6479
push-location $projectDir
6580
# -nobuild <-- this gives an error, but might want to use this to avoid extra builds
66-
dotnet xunit -configuration Release -framework netcoreapp1.1 -xml $reportFile -nobuild
81+
dotnet xunit -configuration Release -framework netcoreapp2.0 -xml $reportFile -nobuild
6782
if ($lastexitcode -ne 0) { exit 1 }
6883
pop-location
6984
}
@@ -73,19 +88,18 @@ function Start-Tests {
7388

7489
function Start-PackNugets {
7590
$projectPaths = @(
76-
"UnitsNet\UnitsNet.NetStandard10.csproj",
77-
"UnitsNet\UnitsNet.NetStandard10.Signed.csproj",
78-
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj",
79-
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Signed.csproj"
91+
"UnitsNet\UnitsNet.csproj",
92+
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
8093
)
8194

8295
write-host -foreground blue "Pack nugets...`n---"
8396
foreach ($projectPath in $projectPaths) {
8497
dotnet pack --configuration Release -o $nugetOutDir "$root\$projectPath"
8598
if ($lastexitcode -ne 0) { exit 1 }
8699
}
87-
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using NuGex.exe instead"
88-
& $nuget pack "$root\UnitsNet\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" -Symbols
100+
101+
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
102+
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
89103

90104
write-host -foreground blue "Pack nugets...END`n"
91105
}
@@ -110,4 +124,4 @@ function Compress-ArtifactsAsZip {
110124
write-host -foreground blue "Zip artifacts...END`n"
111125
}
112126

113-
export-modulemember -function Start-NugetRestore, Remove-ArtifactsDir, Update-GeneratedCode, Start-Build, Start-SignedBuild, Start-Tests, Start-PackNugets, Compress-ArtifactsAsZip
127+
export-modulemember -function Start-NugetRestore, Remove-ArtifactsDir, Update-GeneratedCode, Start-Build, Start-SignedBuild, Start-Tests, Start-PackNugets, Compress-ArtifactsAsZip

Build/build.ps1

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<#
1+
<#
22
.SYNOPSIS
33
Build, run tests and pack nugets for all Units.NET projects.
44
.DESCRIPTION
@@ -7,26 +7,29 @@
77
88
Publishing nugets is handled by nuget-publish.bat and run by the build server
99
on the master branch.
10-
11-
Optional strong name signing .pfx key file to produce signed binaries for the signed nugets.
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.
1213
.EXAMPLE
13-
powershell ./UpdateAssemblyInfo.ps1 c:\UnitsNet_Key.snk
14+
powershell ./build.ps1
15+
powershell ./build.ps1 -skipUWP
1416
1517
.NOTES
1618
Author: Andreas Gullberg Larsen
17-
Last modified: June 1, 2017
19+
Last modified: Jan 21, 2018
1820
#>
1921
[CmdletBinding()]
20-
Param()
22+
Param(
23+
[switch] $skipUWP
24+
)
2125

2226
remove-module build-functions -ErrorAction SilentlyContinue
2327
import-module $PSScriptRoot\build-functions.psm1
2428

2529
try {
2630
Remove-ArtifactsDir
27-
Start-NugetRestore
2831
Update-GeneratedCode
29-
Start-Build
32+
Start-Build $skipUWP
3033
Start-Tests
3134
Start-PackNugets
3235
Compress-ArtifactsAsZip

Build/clean.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

Build/clean.ps1

Lines changed: 25 additions & 6 deletions
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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@
4343
" If not provided, a version number will be generated.`n"
4444
}
4545

46-
# Import functions: Set-ProjectVersion, Bump-ProjectVersion
47-
import-module "$PSScriptRoot\set-version.psm1"
46+
# Import functions: Get-NewProjectVersion, Set-ProjectVersion, Invoke-CommitAndTagVersion
47+
Import-Module "$PSScriptRoot\set-version.psm1"
4848

49+
$root = Resolve-Path "$PSScriptRoot\.."
50+
$paramSet = $PsCmdlet.ParameterSetName
51+
$projFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
52+
$versionFiles = @($projFile)
53+
$projectName = "JsonNet"
4954

50-
$root = "$PSScriptRoot\.."
51-
$paramSet = $PsCmdlet.ParameterSetName
52-
$projectPaths = @("$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Common.props")
53-
$projectName = "JsonNet"
55+
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
56+
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
5457

55-
Set-ProjectVersionAndCommit $projectName $projectPaths $paramSet $setVersion $bumpVersion
58+
Set-ProjectVersion $projFile $newVersion
59+
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion

0 commit comments

Comments
 (0)