From fffde097941da5817f32eef5c2eda06f7c42ba18 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Sat, 26 Dec 2020 07:01:45 +0200 Subject: [PATCH] Update SDK to .NET 5 (#799) --- src/Runner.Common/Runner.Common.csproj | 2 +- src/Runner.Listener/Runner.Listener.csproj | 2 +- .../Runner.PluginHost.csproj | 2 +- .../Artifact/FileContainerServer.cs | 6 ++--- src/Runner.Plugins/Runner.Plugins.csproj | 2 +- src/Runner.Sdk/Runner.Sdk.csproj | 2 +- src/Runner.Worker/Runner.Worker.csproj | 2 +- .../HttpRequestMessageWrapper.cs | 26 +++---------------- .../HttpRequestMessageExtensions.cs | 2 +- .../Common/Common/VssHttpMessageHandler.cs | 4 +-- .../Common/VssHttpMessageHandlerTraceInfo.cs | 6 ++--- .../Common/Common/VssHttpRequestSettings.cs | 4 +-- .../Common/VssHttpRetryMessageHandler.cs | 4 +-- src/Sdk/Sdk.csproj | 2 +- src/Sdk/WebApi/WebApi/VssHttpClientBase.cs | 6 ++--- src/Sdk/WebApi/WebApi/VssRequestTimerTrace.cs | 6 ++--- src/Test/L0/Worker/ActionManagerL0.cs | 8 +++--- src/Test/Test.csproj | 2 +- src/dev.sh | 2 +- src/global.json | 2 +- 20 files changed, 36 insertions(+), 56 deletions(-) diff --git a/src/Runner.Common/Runner.Common.csproj b/src/Runner.Common/Runner.Common.csproj index fbd7da060..d4abe0751 100644 --- a/src/Runner.Common/Runner.Common.csproj +++ b/src/Runner.Common/Runner.Common.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Runner.Listener/Runner.Listener.csproj b/src/Runner.Listener/Runner.Listener.csproj index 925be1acd..24d392b77 100644 --- a/src/Runner.Listener/Runner.Listener.csproj +++ b/src/Runner.Listener/Runner.Listener.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 Exe win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Runner.PluginHost/Runner.PluginHost.csproj b/src/Runner.PluginHost/Runner.PluginHost.csproj index 9d6913209..d1183cdbb 100644 --- a/src/Runner.PluginHost/Runner.PluginHost.csproj +++ b/src/Runner.PluginHost/Runner.PluginHost.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 Exe win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Runner.Plugins/Artifact/FileContainerServer.cs b/src/Runner.Plugins/Artifact/FileContainerServer.cs index 2d838bfeb..62fabf282 100644 --- a/src/Runner.Plugins/Artifact/FileContainerServer.cs +++ b/src/Runner.Plugins/Artifact/FileContainerServer.cs @@ -444,7 +444,7 @@ namespace GitHub.Runner.Plugins.Artifact { // We should never context.Error($"Error '{ex.Message}' when downloading file '{fileToDownload}'. (Downloader {downloaderId})"); - throw ex; + throw; } } @@ -528,7 +528,7 @@ namespace GitHub.Runner.Plugins.Artifact catch (Exception ex) { context.Output($"File error '{ex.Message}' when uploading file '{fileToUpload}'."); - throw ex; + throw; } } @@ -682,4 +682,4 @@ namespace GitHub.Runner.Plugins.Artifact : base(message, inner) { } } -} \ No newline at end of file +} diff --git a/src/Runner.Plugins/Runner.Plugins.csproj b/src/Runner.Plugins/Runner.Plugins.csproj index 7719ee49f..15250a753 100644 --- a/src/Runner.Plugins/Runner.Plugins.csproj +++ b/src/Runner.Plugins/Runner.Plugins.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Runner.Sdk/Runner.Sdk.csproj b/src/Runner.Sdk/Runner.Sdk.csproj index 26f1582e7..9fa4d074d 100644 --- a/src/Runner.Sdk/Runner.Sdk.csproj +++ b/src/Runner.Sdk/Runner.Sdk.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Runner.Worker/Runner.Worker.csproj b/src/Runner.Worker/Runner.Worker.csproj index d4cc3d815..a3351dce5 100644 --- a/src/Runner.Worker/Runner.Worker.csproj +++ b/src/Runner.Worker/Runner.Worker.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 Exe win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Sdk/Common/Common/Authentication/HttpRequestMessageWrapper.cs b/src/Sdk/Common/Common/Authentication/HttpRequestMessageWrapper.cs index ea0a25313..fc3fb4534 100644 --- a/src/Sdk/Common/Common/Authentication/HttpRequestMessageWrapper.cs +++ b/src/Sdk/Common/Common/Authentication/HttpRequestMessageWrapper.cs @@ -12,29 +12,9 @@ namespace GitHub.Services.Common m_request = request; } - public IHttpHeaders Headers - { - get - { - return this; - } - } - - public Uri RequestUri - { - get - { - return m_request.RequestUri; - } - } - - public IDictionary Properties - { - get - { - return m_request.Properties; - } - } + public IHttpHeaders Headers => this; + public Uri RequestUri => m_request.RequestUri; + public IDictionary Properties => m_request.Options; IEnumerable IHttpHeaders.GetValues(String name) { diff --git a/src/Sdk/Common/Common/Diagnostics/HttpRequestMessageExtensions.cs b/src/Sdk/Common/Common/Diagnostics/HttpRequestMessageExtensions.cs index 30279a5c6..b228ab234 100644 --- a/src/Sdk/Common/Common/Diagnostics/HttpRequestMessageExtensions.cs +++ b/src/Sdk/Common/Common/Diagnostics/HttpRequestMessageExtensions.cs @@ -21,7 +21,7 @@ namespace GitHub.Services.Common.Diagnostics public static VssTraceActivity GetActivity(this HttpRequestMessage message) { Object traceActivity; - if (!message.Properties.TryGetValue(VssTraceActivity.PropertyName, out traceActivity)) + if (!message.Options.TryGetValue(VssTraceActivity.PropertyName, out traceActivity)) { return VssTraceActivity.Empty; } diff --git a/src/Sdk/Common/Common/VssHttpMessageHandler.cs b/src/Sdk/Common/Common/VssHttpMessageHandler.cs index e34ceee18..84ac561a1 100644 --- a/src/Sdk/Common/Common/VssHttpMessageHandler.cs +++ b/src/Sdk/Common/Common/VssHttpMessageHandler.cs @@ -169,7 +169,7 @@ namespace GitHub.Services.Common } // Add ourselves to the message so the underlying token issuers may use it if necessary - request.Properties[VssHttpMessageHandler.PropertyName] = this; + request.Options.Set(new HttpRequestOptionsKey(VssHttpMessageHandler.PropertyName), this); Boolean succeeded = false; Boolean lastResponseDemandedProxyAuth = false; @@ -409,7 +409,7 @@ namespace GitHub.Services.Common // Read the completion option provided by the caller. If we don't find the property then we // assume it is OK to buffer by default. HttpCompletionOption completionOption; - if (!request.Properties.TryGetValue(VssHttpRequestSettings.HttpCompletionOptionPropertyName, out completionOption)) + if (!request.Options.TryGetValue(VssHttpRequestSettings.HttpCompletionOptionPropertyName, out completionOption)) { completionOption = HttpCompletionOption.ResponseContentRead; } diff --git a/src/Sdk/Common/Common/VssHttpMessageHandlerTraceInfo.cs b/src/Sdk/Common/Common/VssHttpMessageHandlerTraceInfo.cs index 3b5d63af6..1129f9d81 100644 --- a/src/Sdk/Common/Common/VssHttpMessageHandlerTraceInfo.cs +++ b/src/Sdk/Common/Common/VssHttpMessageHandlerTraceInfo.cs @@ -77,9 +77,9 @@ namespace GitHub.Services.Common public static void SetTraceInfo(HttpRequestMessage message, VssHttpMessageHandlerTraceInfo traceInfo) { object existingTraceInfo; - if (!message.Properties.TryGetValue(TfsTraceInfoKey, out existingTraceInfo)) + if (!message.Options.TryGetValue(TfsTraceInfoKey, out existingTraceInfo)) { - message.Properties.Add(TfsTraceInfoKey, traceInfo); + message.Options.Set(new HttpRequestOptionsKey(TfsTraceInfoKey), traceInfo); } } @@ -92,7 +92,7 @@ namespace GitHub.Services.Common { VssHttpMessageHandlerTraceInfo traceInfo = null; - if (message.Properties.TryGetValue(TfsTraceInfoKey, out object traceInfoObject)) + if (message.Options.TryGetValue(TfsTraceInfoKey, out object traceInfoObject)) { traceInfo = traceInfoObject as VssHttpMessageHandlerTraceInfo; } diff --git a/src/Sdk/Common/Common/VssHttpRequestSettings.cs b/src/Sdk/Common/Common/VssHttpRequestSettings.cs index ac0dd9c3c..ccab94903 100644 --- a/src/Sdk/Common/Common/VssHttpRequestSettings.cs +++ b/src/Sdk/Common/Common/VssHttpRequestSettings.cs @@ -291,12 +291,12 @@ namespace GitHub.Services.Common protected internal virtual Boolean ApplyTo(HttpRequestMessage request) { // Make sure we only apply the settings to the request once - if (request.Properties.ContainsKey(PropertyName)) + if (request.Options.TryGetValue(new HttpRequestOptionsKey(PropertyName), out _)) { return false; } - request.Properties.Add(PropertyName, this); + request.Options.Set(new HttpRequestOptionsKey(PropertyName), this); if (this.AcceptLanguages != null && this.AcceptLanguages.Count > 0) { diff --git a/src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs b/src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs index 69c6dacf2..819949887 100644 --- a/src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs +++ b/src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs @@ -55,7 +55,7 @@ namespace GitHub.Services.Common // Allow overriding default retry options per request VssHttpRetryOptions retryOptions = m_retryOptions; object retryOptionsObject; - if (request.Properties.TryGetValue(HttpRetryOptionsKey, out retryOptionsObject)) // NETSTANDARD compliant, TryGetValue is not + if (request.Options.TryGetValue(HttpRetryOptionsKey, out retryOptionsObject)) // NETSTANDARD compliant, TryGetValue is not { // Fallback to default options if object of unexpected type was passed retryOptions = retryOptionsObject as VssHttpRetryOptions ?? m_retryOptions; @@ -66,7 +66,7 @@ namespace GitHub.Services.Common IVssHttpRetryInfo retryInfo = null; object retryInfoObject; - if (request.Properties.TryGetValue(HttpRetryInfoKey, out retryInfoObject)) // NETSTANDARD compliant, TryGetValue is not + if (request.Options.TryGetValue(HttpRetryInfoKey, out retryInfoObject)) // NETSTANDARD compliant, TryGetValue is not { retryInfo = retryInfoObject as IVssHttpRetryInfo; } diff --git a/src/Sdk/Sdk.csproj b/src/Sdk/Sdk.csproj index bf0c08756..94d569e8b 100644 --- a/src/Sdk/Sdk.csproj +++ b/src/Sdk/Sdk.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 Library win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true diff --git a/src/Sdk/WebApi/WebApi/VssHttpClientBase.cs b/src/Sdk/WebApi/WebApi/VssHttpClientBase.cs index b6c0f5e72..580cb0eaa 100644 --- a/src/Sdk/WebApi/WebApi/VssHttpClientBase.cs +++ b/src/Sdk/WebApi/WebApi/VssHttpClientBase.cs @@ -833,7 +833,7 @@ namespace GitHub.Services.WebApi { if (userState != null) { - message.Properties[UserStatePropertyName] = userState; + message.Options.Set(new HttpRequestOptionsKey(UserStatePropertyName), userState); } if (!message.Headers.Contains(Common.Internal.HttpHeaders.VssE2EID)) @@ -842,11 +842,11 @@ namespace GitHub.Services.WebApi } VssHttpEventSource.Log.HttpRequestStart(traceActivity, message); message.Trace(); - message.Properties[VssTraceActivity.PropertyName] = traceActivity; + message.Options.Set(new HttpRequestOptionsKey(VssTraceActivity.PropertyName), traceActivity); // Send the completion option to the inner handler stack so we know when it's safe to buffer // and when we should avoid buffering. - message.Properties[VssHttpRequestSettings.HttpCompletionOptionPropertyName] = completionOption; + message.Options.Set(new HttpRequestOptionsKey(VssHttpRequestSettings.HttpCompletionOptionPropertyName), completionOption); //ConfigureAwait(false) enables the continuation to be run outside //any captured SyncronizationContext (such as ASP.NET's) which keeps things diff --git a/src/Sdk/WebApi/WebApi/VssRequestTimerTrace.cs b/src/Sdk/WebApi/WebApi/VssRequestTimerTrace.cs index 160f7af60..096ead3e5 100644 --- a/src/Sdk/WebApi/WebApi/VssRequestTimerTrace.cs +++ b/src/Sdk/WebApi/WebApi/VssRequestTimerTrace.cs @@ -18,7 +18,7 @@ namespace GitHub.Services.WebApi { Object tracerObj = null; VssRequestTimerTrace tracer = null; - if (request.Properties.TryGetValue(tracerKey, out tracerObj)) + if (request.Options.TryGetValue(tracerKey, out tracerObj)) { tracer = tracerObj as VssRequestTimerTrace; Debug.Assert(tracer != null, "Tracer object is the wrong type!"); @@ -26,7 +26,7 @@ namespace GitHub.Services.WebApi else { tracer = new VssRequestTimerTrace(); - request.Properties[tracerKey] = tracer; + request.Options.Set(new HttpRequestOptionsKey(tracerKey), tracer); } if (tracer != null) @@ -39,7 +39,7 @@ namespace GitHub.Services.WebApi { Object tracerObj = null; VssRequestTimerTrace tracer = null; - if (response.RequestMessage.Properties.TryGetValue(tracerKey, out tracerObj)) + if (response.RequestMessage.Options.TryGetValue(tracerKey, out tracerObj)) { tracer = tracerObj as VssRequestTimerTrace; Debug.Assert(tracer != null, "Tracer object is the wrong type!"); diff --git a/src/Test/L0/Worker/ActionManagerL0.cs b/src/Test/L0/Worker/ActionManagerL0.cs index 0a343ebc1..4fbd4525b 100644 --- a/src/Test/L0/Worker/ActionManagerL0.cs +++ b/src/Test/L0/Worker/ActionManagerL0.cs @@ -146,7 +146,7 @@ namespace GitHub.Runner.Common.Tests.Worker using var stream = File.OpenRead(archiveFile); var mockClientHandler = new Mock(); mockClientHandler.Protected().Setup>("SendAsync", ItExpr.Is(m => m.RequestUri == new Uri(expectedArchiveLink)), ItExpr.IsAny()) - .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }); + .ReturnsAsync(() => new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }); var mockHandlerFactory = new Mock(); mockHandlerFactory.Setup(p => p.CreateClientHandler(It.IsAny())).Returns(mockClientHandler.Object); @@ -205,9 +205,9 @@ namespace GitHub.Runner.Common.Tests.Worker using var stream = File.OpenRead(archiveFile); var mockClientHandler = new Mock(); mockClientHandler.Protected().Setup>("SendAsync", ItExpr.Is(m => m.RequestUri == new Uri(builtInArchiveLink)), ItExpr.IsAny()) - .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NotFound)); + .ReturnsAsync(() => new HttpResponseMessage(HttpStatusCode.NotFound)); mockClientHandler.Protected().Setup>("SendAsync", ItExpr.Is(m => m.RequestUri == new Uri(dotcomArchiveLink)), ItExpr.IsAny()) - .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }); + .ReturnsAsync(() => new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }); var mockHandlerFactory = new Mock(); mockHandlerFactory.Setup(p => p.CreateClientHandler(It.IsAny())).Returns(mockClientHandler.Object); @@ -265,7 +265,7 @@ namespace GitHub.Runner.Common.Tests.Worker using var stream = File.OpenRead(archiveFile); var mockClientHandler = new Mock(); mockClientHandler.Protected().Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny()) - .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NotFound)); + .ReturnsAsync(() => new HttpResponseMessage(HttpStatusCode.NotFound)); var mockHandlerFactory = new Mock(); mockHandlerFactory.Setup(p => p.CreateClientHandler(It.IsAny())).Returns(mockClientHandler.Object); diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index e6905589d..3dbe8103a 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1 + net5.0 win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64 true portable-net45+win8 diff --git a/src/dev.sh b/src/dev.sh index 15d396c2d..0c1dfe5b5 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -17,7 +17,7 @@ LAYOUT_DIR="$SCRIPT_DIR/../_layout" DOWNLOAD_DIR="$SCRIPT_DIR/../_downloads/netcore2x" PACKAGE_DIR="$SCRIPT_DIR/../_package" DOTNETSDK_ROOT="$SCRIPT_DIR/../_dotnetsdk" -DOTNETSDK_VERSION="3.1.302" +DOTNETSDK_VERSION="5.0.100" DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION" RUNNER_VERSION=$(cat runnerversion) diff --git a/src/global.json b/src/global.json index 2ae03c0b2..ee8f712f9 100644 --- a/src/global.json +++ b/src/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.302" + "version": "5.0.100" } }