From bc71e6c653698347a5fb618026020fd0294e99c2 Mon Sep 17 00:00:00 2001 From: adamjstone <8525409+adamjstone@users.noreply.github.com> Date: Sat, 14 Nov 2020 08:35:58 -0600 Subject: [PATCH] #371 Add .NET 5 SDK to build automation tooling. --- cicd/modules/AutomationTools.psm1 | 66 +++++++++++++++++++ .../SingleThreadLockControlTests.cs | 2 + .../Concurrency/UnconstrainedControlTests.cs | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/cicd/modules/AutomationTools.psm1 b/cicd/modules/AutomationTools.psm1 index 0fa46bac..42cc2672 100644 --- a/cicd/modules/AutomationTools.psm1 +++ b/cicd/modules/AutomationTools.psm1 @@ -36,6 +36,7 @@ $InstallScriptUriForNuGet = "https://dist.nuget.org/win-x86-commandline/v5.1.0/$ # Chocolatey package names $ChoclateyPackageNameForCodecov = "codecov"; $ChoclateyPackageNameForDocFx = "docfx"; +$ChoclateyPackageNameForDotNet5Sdk = "dotnet-5.0-sdk"; $ChoclateyPackageNameForDotNetCoreSdk = "dotnetcore-sdk"; $ChoclateyPackageNameForHub = "hub"; $ChoclateyPackageNameForLeanify = "leanify"; @@ -67,6 +68,7 @@ $CommandNameForOpenSsl = "openssl"; $SuppressChocolatey = $false; $SuppressCodecov = $false; $SuppressDocFx = $false; +$SuppressDotNet5Sdk = $false; $SuppressDotNetCoreSdk = $false; $SuppressHtmlMinifier = $false; $SuppressHub = $true; @@ -112,6 +114,15 @@ Function GetDocFxInstallationStatus Return (GetChocolateyInstallationStatus) -and (choco list -lo | Where-Object { $_.ToLower().StartsWith("$ChoclateyPackageNameForDocFx") }); } +<# +.Synopsis +Returns a boolean value indicating whether or not the .NET 5 SDK is installed in the current environment. +#> +Function GetDotNet5SdkInstallationStatus +{ + Return (GetChocolateyInstallationStatus) -and (choco list -lo | Where-Object { $_.ToLower().StartsWith("$ChoclateyPackageNameForDotNet5Sdk") }); +} + <# .Synopsis Returns a boolean value indicating whether or not the .NET Core SDK is installed in the current environment. @@ -239,6 +250,7 @@ Function InstallAllAutomationTools InstallPackageManagers; InstallCodecov; InstallDocFx; + InstallDotNet5Sdk; InstallDotNetCoreSdk; InstallHtmlMinifier; InstallHub; @@ -323,6 +335,28 @@ Function InstallDocFx ComposeFinish "Finished installing DocFX."; } +<# +.Synopsis +Installs the .NET 5 SDK in the current environment. +#> +Function InstallDotNet5Sdk +{ + If ($SuppressDotNet5Sdk -eq $true) + { + ComposeNormal "Suppressing installation of the .NET 5 SDK."; + Return; + } + ElseIf (GetDotNet5SdkInstallationStatus) + { + ComposeNormal "The .NET 5 SDK is already installed."; + Return; + } + + ComposeStart "Installing the .NET 5 SDK."; + UseChocolateyToInstall -PackageName "$ChoclateyPackageNameForDotNet5Sdk"; + ComposeFinish "Finished installing the .NET 5 SDK."; +} + <# .Synopsis Installs the .NET Core SDK in the current environment. @@ -780,6 +814,18 @@ Function RestoreDocFx ComposeFinish "Finished restoring DocFX."; } +<# +.Synopsis +Uninstalls, if necessary, and installs the .NET 5 SDK in the current environment. +#> +Function RestoreDotNet5Sdk +{ + ComposeStart "Restoring the .NET 5 SDK."; + UninstallDotNet5Sdk; + InstallDotNet5Sdk; + ComposeFinish "Finished restoring the .NET 5 SDK."; +} + <# .Synopsis Uninstalls, if necessary, and installs the .NET Core SDK in the current environment. @@ -945,6 +991,7 @@ Function UninstallAllAutomationTools ComposeStart "Uninstalling all automation tools."; UninstallCodecov; UninstallDocFx; + UninstallDotNet5Sdk; UninstallDotNetCoreSdk; UninstallHtmlMinifier; UninstallHub; @@ -997,6 +1044,25 @@ Function UninstallDocFx } } +<# +.Synopsis +Uninstalls the .NET 5 SDK in the current environment. +#> +Function UninstallDotNet5Sdk +{ + If ($SuppressDotNet5Sdk -eq $true) + { + ComposeNormal "Suppressing uninstallation of the .NET 5 SDK."; + Return; + } + ElseIf (GetDotNet5SdkInstallationStatus) + { + ComposeStart "Uninstalling the .NET 5 SDK."; + UseChocolateyToUninstall -PackageName "$ChoclateyPackageNameForDotNet5Sdk"; + ComposeFinish "Finished uninstalling the .NET 5 SDK."; + } +} + <# .Synopsis Uninstalls the .NET Core SDK in the current environment. diff --git a/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/SingleThreadLockControlTests.cs b/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/SingleThreadLockControlTests.cs index fc85d7d7..5a739b95 100644 --- a/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/SingleThreadLockControlTests.cs +++ b/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/SingleThreadLockControlTests.cs @@ -38,7 +38,9 @@ private static void PerformUsingPrimitive(Action> perform) var syncRoot = new Object(); perform((operation) => { +#pragma warning disable PH_P006 Monitor.Enter(syncRoot); +#pragma warning restore PH_P006 try { diff --git a/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/UnconstrainedControlTests.cs b/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/UnconstrainedControlTests.cs index dad56afe..b9561ce5 100644 --- a/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/UnconstrainedControlTests.cs +++ b/test/RapidField.SolidInstruments.Core.UnitTests/Concurrency/UnconstrainedControlTests.cs @@ -26,7 +26,7 @@ public void OperationLatency_ShouldBeLow() { // Arrange. var mode = ConcurrencyControlMode.Unconstrained; - var latencyThresholdInTicks = 987; + var latencyThresholdInTicks = 2584; // Assert. ConcurrencyControlTests.OperationLatency_ShouldBeLow(mode, PerformUsingPrimitive, latencyThresholdInTicks);