From 2a521681156cfd8b297572a7fb19e96812c92d7b Mon Sep 17 00:00:00 2001 From: samsosa <32570890+samsosa@users.noreply.github.com> Date: Mon, 17 Feb 2020 08:07:32 +0100 Subject: [PATCH 01/13] Remove HostString.Port string alloc in HostString.cs (#19082) https://github.com/dotnet/aspnetcore/issues/19064 --- src/Http/Http.Abstractions/src/HostString.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Http.Abstractions/src/HostString.cs b/src/Http/Http.Abstractions/src/HostString.cs index 0f7cbd73f6..c15d59bf56 100644 --- a/src/Http/Http.Abstractions/src/HostString.cs +++ b/src/Http/Http.Abstractions/src/HostString.cs @@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Http GetParts(_value, out var host, out var port); if (!StringSegment.IsNullOrEmpty(port) - && int.TryParse(port.ToString(), NumberStyles.None, CultureInfo.InvariantCulture, out var p)) + && int.TryParse(port.AsSpan(), NumberStyles.None, CultureInfo.InvariantCulture, out var p)) { return p; } From 211bc40384f35b74e70fd383b6f93097f352bb99 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 18 Feb 2020 09:26:51 -0800 Subject: [PATCH 02/13] Revert flaky tests that seems to have been fixed (#19065) --- .azure/pipelines/ci.yml | 1 + .../Microsoft.dotnet-openapi/test/OpenApiAddFileTests.cs | 8 -------- .../Microsoft.dotnet-openapi/test/OpenApiRemoveTests.cs | 3 --- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index dee7ba6985..19a90ec662 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -591,6 +591,7 @@ stages: - template: jobs/default-build.yml parameters: + condition: ne(variables['Build.Reason'], 'PullRequest') jobName: Helix_x64_daily jobDisplayName: 'Tests: Helix x64 Daily' agentOs: Windows diff --git a/src/Tools/Microsoft.dotnet-openapi/test/OpenApiAddFileTests.cs b/src/Tools/Microsoft.dotnet-openapi/test/OpenApiAddFileTests.cs index 8af04058c0..c277df763d 100644 --- a/src/Tools/Microsoft.dotnet-openapi/test/OpenApiAddFileTests.cs +++ b/src/Tools/Microsoft.dotnet-openapi/test/OpenApiAddFileTests.cs @@ -28,7 +28,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public void OpenApi_NoProjectExists() { var app = GetApplication(); @@ -40,7 +39,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public void OpenApi_ExplicitProject_Missing() { var app = GetApplication(); @@ -75,7 +73,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Add_ReuseItemGroup() { var project = CreateBasicProject(withOpenApi: true); @@ -105,7 +102,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public void OpenApi_Add_File_EquivilentPaths() { var project = CreateBasicProject(withOpenApi: true); @@ -131,7 +127,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Add_NSwagTypeScript() { var project = CreateBasicProject(withOpenApi: true); @@ -152,7 +147,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Add_FromJson() { var project = CreateBasicProject(withOpenApi: true); @@ -173,7 +167,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Add_File_UseProjectOption() { var project = CreateBasicProject(withOpenApi: true); @@ -194,7 +187,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Add_MultipleTimes_OnlyOneReference() { var project = CreateBasicProject(withOpenApi: true); diff --git a/src/Tools/Microsoft.dotnet-openapi/test/OpenApiRemoveTests.cs b/src/Tools/Microsoft.dotnet-openapi/test/OpenApiRemoveTests.cs index b48b7f688c..a8db61e99a 100644 --- a/src/Tools/Microsoft.dotnet-openapi/test/OpenApiRemoveTests.cs +++ b/src/Tools/Microsoft.dotnet-openapi/test/OpenApiRemoveTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.DotNet.OpenApi.Remove.Tests public OpenApiRemoveTests(ITestOutputHelper output) : base(output) { } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Remove_File() { var nswagJsonFile = "openapi.json"; @@ -62,7 +61,6 @@ namespace Microsoft.DotNet.OpenApi.Remove.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Remove_ViaUrl() { _tempDir @@ -151,7 +149,6 @@ namespace Microsoft.DotNet.OpenApi.Remove.Tests } [Fact] - [Flaky("", FlakyOn.All)] public async Task OpenApi_Remove_Multiple() { var nswagJsonFile = "openapi.json"; From 4895f516288388b26989623ff4250f90f796e8e1 Mon Sep 17 00:00:00 2001 From: William Godbe Date: Tue, 18 Feb 2020 11:43:35 -0800 Subject: [PATCH 03/13] Pin dependency on Microsoft.CSharp (#19063) * Pin dependency on Microsoft.CSharp * Use 4.7.0 version * Remove CSharp for versions.details.xml * Move Microsoft.CSharp to manual section of versions.props --- eng/Version.Details.xml | 4 ---- eng/Versions.props | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 36195e902f..9034ddd9e1 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -289,10 +289,6 @@ https://github.com/dotnet/extensions 396aff55e0b4628a7a44375e4b72e5d19a6e37ab - - https://github.com/dotnet/corefx - 5cee7c97d602f294e27c582d4dab81ec388f1d7b - https://github.com/dotnet/runtime 0f3f8e1930c28b67f29990126bc2e8527e959a2e diff --git a/eng/Versions.props b/eng/Versions.props index d399cc3304..91bac37df5 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -63,14 +63,12 @@ 5.0.0-beta.20113.3 3.5.0-beta3-20114-02 - + 5.0.0-preview.1.20113.7 5.0.0-preview.1.20113.7 5.0.0-preview.1.20113.7 5.0.0-preview.1.20113.7 2.1.0-preview.1.20113.7 - - 5.0.0-alpha.1.19563.6 5.0.0-preview.1.20113.7 5.0.0-preview.1.20113.7 5.0.0-preview.1.20113.7 @@ -192,6 +190,7 @@ 1.0.0-beta-64023-03 15.9.3032 + 4.7.0 4.5.0 4.4.0 0.3.0-alpha.19317.1 From abfd519b408e9daff672f31d6829d0738bb10842 Mon Sep 17 00:00:00 2001 From: Greg Ingram Date: Tue, 18 Feb 2020 18:48:22 -0500 Subject: [PATCH 04/13] Updated summary (#19087) --- .../Connections.Abstractions/src/ConnectionHandler.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Servers/Connections.Abstractions/src/ConnectionHandler.cs b/src/Servers/Connections.Abstractions/src/ConnectionHandler.cs index e9e208d61a..9bc8ab2902 100644 --- a/src/Servers/Connections.Abstractions/src/ConnectionHandler.cs +++ b/src/Servers/Connections.Abstractions/src/ConnectionHandler.cs @@ -6,15 +6,15 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Connections { /// - /// Represents an end point that multiple connections connect to. For HTTP, endpoints are URLs, for non HTTP it can be a TCP listener (or similar) + /// Represents an endpoint that multiple connections connect to. For HTTP, endpoints are URLs, for non-HTTP it can be a TCP listener (or similar). /// public abstract class ConnectionHandler { /// - /// Called when a new connection is accepted to the endpoint + /// Called when a new connection is accepted to the endpoint. /// /// The new /// A that represents the connection lifetime. When the task completes, the connection is complete. public abstract Task OnConnectedAsync(ConnectionContext connection); } -} \ No newline at end of file +} From 853d8f02e76a4beede6f6f883f96703943cfb38a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 18 Feb 2020 15:51:13 -0800 Subject: [PATCH 05/13] Use dotnet-helixapi-access token for internal helix builds --- .azure/pipelines/ci.yml | 8 ++++++++ eng/helix/helix.proj | 12 ++++++++---- eng/targets/Helix.targets | 6 ++++++ .../test/FunctionalTests/Http2/HandshakeTests.cs | 4 ++-- .../test/FunctionalTests/Http2/ShutdownTests.cs | 4 ++-- .../HttpsConnectionMiddlewareTests.cs | 2 +- .../test/Interop.FunctionalTests/Utilities.cs | 2 +- 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index 19a90ec662..f5aea4cc0b 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -38,7 +38,12 @@ variables: value: '' - name: _SignType value: '' + - name: _UseHelixOpenQueues + value: 'true' - ${{ if eq(variables['System.TeamProject'], 'internal') }}: + - group: DotNet-HelixApi-Access + - name: _UseHelixOpenQueues + value: 'false' - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: # DotNet-Blob-Feed provides: dotnetfeed-storage-access-key-1 # Publish-Build-Assets provides: MaestroAccessToken, BotAccount-dotnet-maestro-bot-PAT @@ -582,6 +587,7 @@ stages: - script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl displayName: Run build.cmd helix target env: + HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops artifacts: - name: Helix_logs @@ -602,6 +608,7 @@ stages: - script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:IsHelixJob=true /p:IsHelixDaily=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl displayName: Run build.cmd helix target env: + HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops artifacts: - name: Helix_logs @@ -623,6 +630,7 @@ stages: - script: ./build.sh -ci --arch arm64 -test --no-build-nodejs -projects $(Build.SourcesDirectory)/eng/helix/helix.proj /p:IsHelixJob=true /p:IsHelixDaily=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl displayName: Run build.sh helix arm64 target env: + HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops installNodeJs: false artifacts: diff --git a/eng/helix/helix.proj b/eng/helix/helix.proj index 1db18afa98..b905693145 100644 --- a/eng/helix/helix.proj +++ b/eng/helix/helix.proj @@ -12,7 +12,8 @@ - + + @@ -21,11 +22,13 @@ true true 2 + $(HelixApiAccessToken) ci - aspnetcore + + aspnetcore $(BUILD_BUILDNUMBER).$(TargetArchitecture).$(SYSTEM_JOBATTEMPT) true true @@ -34,8 +37,9 @@ dev - $(USERNAME) - $(USER) + + $(USERNAME) + $(USER) $([System.DateTime]::Now.ToString('yyyyMMddHHmm')) diff --git a/eng/targets/Helix.targets b/eng/targets/Helix.targets index c6a20b6055..f3d1ad0f16 100644 --- a/eng/targets/Helix.targets +++ b/eng/targets/Helix.targets @@ -40,6 +40,12 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj <_SelectedPlatforms>@(HelixProjectPlatform) + + <_Temp Include="@(HelixAvailableTargetQueue)" /> + + + + <_HelixProjectTargetQueue Include="%(HelixAvailableTargetQueue.Identity)" Condition="'%(HelixAvailableTargetQueue.Identity)' != '' AND '$(_SelectedPlatforms.Contains(%(Platform)))' == 'true'" /> diff --git a/src/Servers/Kestrel/test/FunctionalTests/Http2/HandshakeTests.cs b/src/Servers/Kestrel/test/FunctionalTests/Http2/HandshakeTests.cs index 66a31011bb..7ffd9b2bc0 100644 --- a/src/Servers/Kestrel/test/FunctionalTests/Http2/HandshakeTests.cs +++ b/src/Servers/Kestrel/test/FunctionalTests/Http2/HandshakeTests.cs @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2 [ConditionalFact] [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")] - [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64;Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)] public async Task TlsAlpnHandshakeSelectsHttp2From1and2() { @@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2 [ConditionalFact] [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")] - [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64;Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)] public async Task TlsAlpnHandshakeSelectsHttp2() { diff --git a/src/Servers/Kestrel/test/FunctionalTests/Http2/ShutdownTests.cs b/src/Servers/Kestrel/test/FunctionalTests/Http2/ShutdownTests.cs index 8d93032449..7bed5ea335 100644 --- a/src/Servers/Kestrel/test/FunctionalTests/Http2/ShutdownTests.cs +++ b/src/Servers/Kestrel/test/FunctionalTests/Http2/ShutdownTests.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2 { [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")] [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10)] - [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64;Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 public class ShutdownTests : TestApplicationErrorLoggerLoggedTest { private static X509Certificate2 _x509Certificate2 = TestResources.GetTestCertificate(); @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2 [CollectDump] [ConditionalFact] - [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/9985", Queues = "Fedora.28.Amd64.Open")] + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/9985", Queues = "Fedora.28.Amd64;Fedora.28.Amd64.Open")] [Flaky("https://github.com/dotnet/aspnetcore/issues/9985", FlakyOn.All)] public async Task GracefulShutdownWaitsForRequestsToFinish() { diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs index b7af0267e5..80780257e4 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs @@ -595,7 +595,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests [InlineData(HttpProtocols.Http2)] [InlineData(HttpProtocols.Http1AndHttp2)] [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")] - [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64;Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2 [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)] public async Task ListenOptionsProtolsCanBeSetAfterUseHttps(HttpProtocols httpProtocols) { diff --git a/src/Servers/Kestrel/test/Interop.FunctionalTests/Utilities.cs b/src/Servers/Kestrel/test/Interop.FunctionalTests/Utilities.cs index 1e6fb930f8..db41d1e1b4 100644 --- a/src/Servers/Kestrel/test/Interop.FunctionalTests/Utilities.cs +++ b/src/Servers/Kestrel/test/Interop.FunctionalTests/Utilities.cs @@ -14,7 +14,7 @@ namespace Interop.FunctionalTests // "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492" && new OSSkipConditionAttribute(OperatingSystems.MacOSX).IsMet // Debian 8 uses OpenSSL 1.0.1 which does not support ALPN - && new SkipOnHelixAttribute("https://github.com/dotnet/aspnetcore/issues/10428") { Queues = "Debian.8.Amd64.Open" }.IsMet; + && new SkipOnHelixAttribute("https://github.com/dotnet/aspnetcore/issues/10428") { Queues = "Debian.8.Amd64;Debian.8.Amd64.Open" }.IsMet; } } } From e937884eb43e40d89a8c02ecea38bf1ec3f2d055 Mon Sep 17 00:00:00 2001 From: Scott Addie <10702007+scottaddie@users.noreply.github.com> Date: Wed, 19 Feb 2020 12:25:28 -0600 Subject: [PATCH 06/13] Secret Manager: Save project file without XML declaration (#14354) --- .../dotnet-user-secrets/src/Internal/InitCommand.cs | 12 +++++++++++- .../dotnet-user-secrets/test/InitCommandTest.cs | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs b/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs index e54f04ff7c..5b8b038596 100644 --- a/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs +++ b/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using System.Xml; using System.Xml.Linq; using System.Xml.XPath; using Microsoft.Extensions.CommandLineUtils; @@ -122,7 +123,16 @@ namespace Microsoft.Extensions.SecretManager.Tools.Internal propertyGroup.Add(new XElement("UserSecretsId", newSecretsId)); } - projectDocument.Save(projectPath); + var settings = new XmlWriterSettings + { + Indent = true, + OmitXmlDeclaration = true, + }; + + using (var xw = XmlWriter.Create(projectPath, settings)) + { + projectDocument.Save(xw); + } context.Reporter.Output(Resources.FormatMessage_SetUserSecretsIdForProject(newSecretsId, projectPath)); } diff --git a/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs b/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs index 562f149ca4..ee0efce15f 100644 --- a/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs +++ b/src/Tools/dotnet-user-secrets/test/InitCommandTest.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Text; +using System.Xml.Linq; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Configuration.UserSecrets.Tests; using Microsoft.Extensions.SecretManager.Tools.Internal; @@ -90,6 +91,18 @@ namespace Microsoft.Extensions.SecretManager.Tools.Tests Assert.Equal(SecretId, idResolver.Resolve(null, null)); } + [Fact] + public void DoesNotAddXmlDeclarationToProject() + { + var projectDir = _fixture.CreateProject(null); + var projectFile = Path.Combine(projectDir, "TestProject.csproj"); + + new InitCommand(null, null).Execute(MakeCommandContext(), projectDir); + + var projectDocument = XDocument.Load(projectFile); + Assert.Null(projectDocument.Declaration); + } + [Fact] public void OverridesIdForProjectWithSecretId() { From 1e4438647c834c3ffa9474d04b48d4a72c3e8978 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Wed, 19 Feb 2020 22:54:35 +0330 Subject: [PATCH 07/13] Add Email claim (#18580) --- ...oft.Extensions.Identity.Core.netcoreapp.cs | 1 + ...Extensions.Identity.Core.netstandard2.0.cs | 1 + .../src/ClaimsIdentityOptions.cs | 7 ++++- .../src/UserClaimsPrincipalFactory.cs | 10 ++++++- .../UserClaimsPrincipalFactoryTest.cs | 28 +++++++++++++------ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs index 13979d60ae..fa44115139 100644 --- a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs +++ b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netcoreapp.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.Identity public partial class ClaimsIdentityOptions { public ClaimsIdentityOptions() { } + public string EmailClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string RoleClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string SecurityStampClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string UserIdClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } diff --git a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs index 13979d60ae..fa44115139 100644 --- a/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs +++ b/src/Identity/Extensions.Core/ref/Microsoft.Extensions.Identity.Core.netstandard2.0.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.Identity public partial class ClaimsIdentityOptions { public ClaimsIdentityOptions() { } + public string EmailClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string RoleClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string SecurityStampClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string UserIdClaimType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } diff --git a/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs b/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs index 54ba1ae069..17f383ab33 100644 --- a/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs +++ b/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs @@ -25,9 +25,14 @@ namespace Microsoft.AspNetCore.Identity /// public string UserIdClaimType { get; set; } = ClaimTypes.NameIdentifier; + /// + /// Gets or sets the ClaimType used for the user email claim. Defaults to . + /// + public string EmailClaimType { get; set; } = ClaimTypes.Email; + /// /// Gets or sets the ClaimType used for the security stamp claim. Defaults to "AspNet.Identity.SecurityStamp". /// public string SecurityStampClaimType { get; set; } = "AspNet.Identity.SecurityStamp"; } -} \ No newline at end of file +} diff --git a/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs b/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs index dd7e316423..859e78ad57 100644 --- a/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs +++ b/src/Identity/Extensions.Core/src/UserClaimsPrincipalFactory.cs @@ -81,6 +81,14 @@ namespace Microsoft.AspNetCore.Identity Options.ClaimsIdentity.RoleClaimType); id.AddClaim(new Claim(Options.ClaimsIdentity.UserIdClaimType, userId)); id.AddClaim(new Claim(Options.ClaimsIdentity.UserNameClaimType, userName)); + if (UserManager.SupportsUserEmail) + { + var email = await UserManager.GetEmailAsync(user); + if (!string.IsNullOrEmpty(email)) + { + id.AddClaim(new Claim(Options.ClaimsIdentity.EmailClaimType, email)); + } + } if (UserManager.SupportsUserSecurityStamp) { id.AddClaim(new Claim(Options.ClaimsIdentity.SecurityStampClaimType, @@ -154,4 +162,4 @@ namespace Microsoft.AspNetCore.Identity return id; } } -} \ No newline at end of file +} diff --git a/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs b/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs index befed38dd9..bcf42f459d 100644 --- a/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs +++ b/src/Identity/test/Identity.Test/UserClaimsPrincipalFactoryTest.cs @@ -30,22 +30,33 @@ namespace Microsoft.AspNetCore.Identity.Test } [Theory] - [InlineData(false, false, false)] - [InlineData(false, true, false)] - [InlineData(true, false, false)] - [InlineData(true, true, false)] - [InlineData(true, false, true)] - [InlineData(true, true, true)] - public async Task EnsureClaimsIdentityHasExpectedClaims(bool supportRoles, bool supportClaims, bool supportRoleClaims) + [InlineData(true, false, false, false)] + [InlineData(true, true, false, false)] + [InlineData(true, false, true, false)] + [InlineData(true, true, true, false)] + [InlineData(false, false, false, true)] + [InlineData(false, true, false, true)] + [InlineData(false, false, false, false)] + [InlineData(false, true, false, false)] + [InlineData(true, false, false, true)] + [InlineData(true, true, false, true)] + [InlineData(true, false, true, true)] + [InlineData(true, true, true, true)] + public async Task EnsureClaimsIdentityHasExpectedClaims(bool supportRoles, bool supportClaims, bool supportRoleClaims, bool supportsUserEmail) { // Setup var userManager = MockHelpers.MockUserManager(); var roleManager = MockHelpers.MockRoleManager(); - var user = new PocoUser { UserName = "Foo" }; + var user = new PocoUser { UserName = "Foo", Email = "foo@bar.com" }; userManager.Setup(m => m.SupportsUserClaim).Returns(supportClaims); userManager.Setup(m => m.SupportsUserRole).Returns(supportRoles); + userManager.Setup(m => m.SupportsUserEmail).Returns(supportsUserEmail); userManager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id); userManager.Setup(m => m.GetUserNameAsync(user)).ReturnsAsync(user.UserName); + if (supportsUserEmail) + { + userManager.Setup(m => m.GetEmailAsync(user)).ReturnsAsync(user.Email); + } var roleClaims = new[] { "Admin", "Local" }; if (supportRoles) { @@ -90,6 +101,7 @@ namespace Microsoft.AspNetCore.Identity.Test Assert.Contains( claims, c => c.Type == manager.Options.ClaimsIdentity.UserNameClaimType && c.Value == user.UserName); Assert.Contains(claims, c => c.Type == manager.Options.ClaimsIdentity.UserIdClaimType && c.Value == user.Id); + Assert.Equal(supportsUserEmail, claims.Any(c => c.Type == manager.Options.ClaimsIdentity.EmailClaimType && c.Value == user.Email)); Assert.Equal(supportRoles, claims.Any(c => c.Type == manager.Options.ClaimsIdentity.RoleClaimType && c.Value == "Admin")); Assert.Equal(supportRoles, claims.Any(c => c.Type == manager.Options.ClaimsIdentity.RoleClaimType && c.Value == "Local")); foreach (var cl in userClaims) From e3a5f03e2474b08c75911dc959f63ae37a0594f5 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 19 Feb 2020 13:18:12 -0800 Subject: [PATCH 08/13] Run Java tests on Helix (#18938) --- .azure/pipelines/jobs/default-build.yml | 2 +- .gitattributes | 5 ++ Directory.Build.props | 1 + Directory.Build.targets | 1 + eng/helix/content/InstallJdk.ps1 | 62 +++++++++++++++++++ eng/helix/content/installjdk.sh | 46 ++++++++++++++ eng/helix/content/installnode.sh | 12 +++- eng/targets/CSharp.Common.props | 1 - eng/targets/CSharp.Common.targets | 2 +- eng/targets/Helix.props | 14 +---- eng/targets/Helix.targets | 20 +++++- eng/targets/Npm.Common.targets | 2 +- .../CommonLibTests/CommonLibTests.vcxproj | 3 + src/SignalR/clients/java/signalr/.gitignore | 1 + src/SignalR/clients/java/signalr/build.gradle | 6 +- ...roj => signalr.client.java.Tests.javaproj} | 31 +++++++++- .../SignalR.Npm.FunctionalTests.npmproj | 3 +- 17 files changed, 188 insertions(+), 24 deletions(-) create mode 100644 eng/helix/content/InstallJdk.ps1 create mode 100644 eng/helix/content/installjdk.sh rename src/SignalR/clients/java/signalr/{signalr.client.java.javaproj => signalr.client.java.Tests.javaproj} (67%) diff --git a/.azure/pipelines/jobs/default-build.yml b/.azure/pipelines/jobs/default-build.yml index d9a4e1b58a..dad5a3b6f1 100644 --- a/.azure/pipelines/jobs/default-build.yml +++ b/.azure/pipelines/jobs/default-build.yml @@ -233,7 +233,7 @@ jobs: condition: always() inputs: testRunner: junit - testResultsFiles: '**/TEST-com.microsoft.signalr*.xml' + testResultsFiles: '**/TEST-junit-jupiter.xml' buildConfiguration: $(BuildConfiguration) buildPlatform: $(AgentOsName) mergeTestResults: true diff --git a/.gitattributes b/.gitattributes index ff67a9158f..3225eae5e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,6 +8,11 @@ ############################################################################### *.sh eol=lf +############################################################################### +# Make gradlew always have LF as line endings +############################################################################### +gradlew eol=lf + ############################################################################### # Set default behavior for command prompt diff. # diff --git a/Directory.Build.props b/Directory.Build.props index b68fd8cb66..a4b4790b40 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -187,5 +187,6 @@ + diff --git a/Directory.Build.targets b/Directory.Build.targets index 01c320019a..c961c8db3e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -163,5 +163,6 @@ + diff --git a/eng/helix/content/InstallJdk.ps1 b/eng/helix/content/InstallJdk.ps1 new file mode 100644 index 0000000000..a9346062fa --- /dev/null +++ b/eng/helix/content/InstallJdk.ps1 @@ -0,0 +1,62 @@ +<# +.SYNOPSIS + Installs JDK into a folder in this repo. +.DESCRIPTION + This script downloads an extracts the JDK. +.PARAMETER JdkVersion + The version of the JDK to install. If not set, the default value is read from global.json +.PARAMETER Force + Overwrite the existing installation +#> +param( + [string]$JdkVersion, + [Parameter(Mandatory = $false)] + $InstallDir +) +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138 + +Set-StrictMode -Version 1 + +if ($InstallDir) { + $installDir = $InstallDir; +} +else { + $repoRoot = Resolve-Path "$PSScriptRoot\..\.." + $installDir = "$repoRoot\.tools\jdk\win-x64\" +} +$tempDir = "$installDir\obj" +if (-not $JdkVersion) { + $globalJson = Get-Content "$repoRoot\global.json" | ConvertFrom-Json + $JdkVersion = $globalJson.tools.jdk +} + +if (Test-Path $installDir) { + if ($Force) { + Remove-Item -Force -Recurse $installDir + } + else { + Write-Host "The JDK already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite." + exit 0 + } +} + +Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null +mkdir $tempDir -ea Ignore | out-null +mkdir $installDir -ea Ignore | out-null +Write-Host "Starting download of JDK ${JdkVersion}" +Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -OutFile "$tempDir/jdk.zip" +Write-Host "Done downloading JDK ${JdkVersion}" + +Add-Type -assembly "System.IO.Compression.FileSystem" +[System.IO.Compression.ZipFile]::ExtractToDirectory("$tempDir/jdk.zip", "$tempDir/jdk/") + +Write-Host "Expanded JDK to $tempDir" +Write-Host "Installing JDK to $installDir" +Move-Item "$tempDir/jdk/jdk-${JdkVersion}/*" $installDir +Write-Host "Done installing JDK to $installDir" +Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null + +if ($env:TF_BUILD) { + Write-Host "##vso[task.prependpath]$installDir\bin" +} diff --git a/eng/helix/content/installjdk.sh b/eng/helix/content/installjdk.sh new file mode 100644 index 0000000000..6c1c2ff5c6 --- /dev/null +++ b/eng/helix/content/installjdk.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Cause the script to fail if any subcommand fails +set -e + +pushd . + +if [ "$JAVA_HOME" != "" ]; then + echo "JAVA_HOME is set" + exit +fi + +java_version=$1 +arch=$2 +osname=`uname -s` +if [ "$osname" = "Darwin" ]; then + echo "macOS not supported, relying on the machine providing java itself" + exit 1 +else + platformarch="linux-$arch" +fi +echo "PlatformArch: $platformarch" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +output_dir="$DIR/java" +url="https://netcorenativeassets.blob.core.windows.net/resource-packages/external/linux/java/jdk-${java_version}_${platformarch}_bin.tar.gz" +echo "Downloading from: $url" +tmp="$(mktemp -d -t install-jdk.XXXXXX)" + +cleanup() { + exitcode=$? + if [ $exitcode -ne 0 ]; then + echo "Failed to install java with exit code: $exitcode" + fi + rm -rf "$tmp" + exit $exitcode +} + +trap "cleanup" EXIT +cd "$tmp" +curl -Lsfo $(basename $url) "$url" +echo "Installing java from $(basename $url) $url" +mkdir $output_dir +echo "Unpacking to $output_dir" +tar --strip-components 1 -xzf "jdk-${java_version}_${platformarch}_bin.tar.gz" --no-same-owner --directory "$output_dir" + +popd \ No newline at end of file diff --git a/eng/helix/content/installnode.sh b/eng/helix/content/installnode.sh index 0442958ac2..db5d2fa5a5 100644 --- a/eng/helix/content/installnode.sh +++ b/eng/helix/content/installnode.sh @@ -22,7 +22,17 @@ output_dir="$DIR/node" url="http://nodejs.org/dist/v$node_version/node-v$node_version-$platformarch.tar.gz" echo "Downloading from: $url" tmp="$(mktemp -d -t install-node.XXXXXX)" -trap "rm -rf $tmp" EXIT + +cleanup() { + exitcode=$? + if [ $exitcode -ne 0 ]; then + echo "Failed to install node with exit code: $exitcode" + fi + rm -rf "$tmp" + exit $exitcode +} + +trap "cleanup" EXIT cd "$tmp" curl -Lsfo $(basename $url) "$url" echo "Installing node from $(basename $url) $url" diff --git a/eng/targets/CSharp.Common.props b/eng/targets/CSharp.Common.props index 6cc6bd2dd8..4600fad635 100644 --- a/eng/targets/CSharp.Common.props +++ b/eng/targets/CSharp.Common.props @@ -35,6 +35,5 @@ - diff --git a/eng/targets/CSharp.Common.targets b/eng/targets/CSharp.Common.targets index 877665a63b..e327a7b886 100644 --- a/eng/targets/CSharp.Common.targets +++ b/eng/targets/CSharp.Common.targets @@ -30,5 +30,5 @@ - + diff --git a/eng/targets/Helix.props b/eng/targets/Helix.props index 40e9420500..d36c4a1a7a 100644 --- a/eng/targets/Helix.props +++ b/eng/targets/Helix.props @@ -15,6 +15,8 @@ false false true + false + true $(MSBuildProjectName)--$(TargetFramework) false false @@ -33,16 +35,4 @@ - - - - - - - - - - - - diff --git a/eng/targets/Helix.targets b/eng/targets/Helix.targets index f3d1ad0f16..eecd36f02a 100644 --- a/eng/targets/Helix.targets +++ b/eng/targets/Helix.targets @@ -1,10 +1,26 @@ + + + + + + + + + + + + + + + + - + @@ -91,6 +108,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj @(HelixPostCommand) call runtests.cmd $(TargetFileName) $(TargetFrameworkIdentifier) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) ./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) + $(HelixCommand) $(HelixTimeout) diff --git a/eng/targets/Npm.Common.targets b/eng/targets/Npm.Common.targets index fd15a8e45e..3460edde2e 100644 --- a/eng/targets/Npm.Common.targets +++ b/eng/targets/Npm.Common.targets @@ -119,7 +119,7 @@ - + diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj index d8d0ef653b..a49803ecce 100644 --- a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj +++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj @@ -1,4 +1,7 @@  + + false + Debug diff --git a/src/SignalR/clients/java/signalr/.gitignore b/src/SignalR/clients/java/signalr/.gitignore index eabba7738e..3e9534ce39 100644 --- a/src/SignalR/clients/java/signalr/.gitignore +++ b/src/SignalR/clients/java/signalr/.gitignore @@ -2,6 +2,7 @@ .gradletasknamecache .gradle/ build/ +/test-results .settings/ out/ *.class diff --git a/src/SignalR/clients/java/signalr/build.gradle b/src/SignalR/clients/java/signalr/build.gradle index 4b18bba589..b845d83949 100644 --- a/src/SignalR/clients/java/signalr/build.gradle +++ b/src/SignalR/clients/java/signalr/build.gradle @@ -6,6 +6,7 @@ buildscript { } dependencies { classpath "com.diffplug.spotless:spotless-plugin-gradle:3.14.0" + classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0' } } @@ -16,6 +17,7 @@ plugins { apply plugin: "java-library" apply plugin: "com.diffplug.gradle.spotless" +apply plugin: 'org.junit.platform.gradle.plugin' group 'com.microsoft.signalr' @@ -64,8 +66,8 @@ spotless { } } -test { - useJUnitPlatform() +junitPlatform { + reportsDir file('test-results') } task sourceJar(type: Jar) { diff --git a/src/SignalR/clients/java/signalr/signalr.client.java.javaproj b/src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj similarity index 67% rename from src/SignalR/clients/java/signalr/signalr.client.java.javaproj rename to src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj index 15eeed479f..d037c1468f 100644 --- a/src/SignalR/clients/java/signalr/signalr.client.java.javaproj +++ b/src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj @@ -1,5 +1,5 @@ - - + + @@ -15,6 +15,9 @@ $(GradleOptions) -Dorg.gradle.daemon=false + $(OutputPath) + true + @@ -51,15 +54,37 @@ - + + + + + + + + + + + + + + + $(GradleOptions) -PpackageVersion="$(PackageVersion)" + chmod +x ./gradlew && ./gradlew $(GradleOptions) test + call gradlew $(GradleOptions) test + + + + + + diff --git a/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj b/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj index 6314e22990..8f89229340 100644 --- a/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj +++ b/src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj @@ -9,6 +9,7 @@ <_TestSauceArgs Condition="'$(BrowserTestHostName)' != ''">$(_TestSauceArgs) --use-hostname "$(BrowserTestHostName)" run test:inner --no-color --configuration $(Configuration) run build:inner + false @@ -18,7 +19,7 @@ - + From 76d197f0dd0d0835585d82540f35acde9db5a0d5 Mon Sep 17 00:00:00 2001 From: Roman Marusyk Date: Wed, 19 Feb 2020 23:39:24 +0200 Subject: [PATCH 09/13] Add XML Documentation to ResponseCachingMiddleware and ResponseCachingExtensions (#18968) * Add XML Documentation to ResponseCachingMiddleware and ResponseCachingExtensions * Update src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs Co-Authored-By: Andrew Stanton-Nurse * Update src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs Co-Authored-By: Andrew Stanton-Nurse * Update ResponseCachingMiddleware.cs Co-authored-by: Andrew Stanton-Nurse --- .../src/ResponseCachingExtensions.cs | 7 +++++++ .../src/ResponseCachingMiddleware.cs | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs b/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs index 45d905cea6..8dff8eb2f5 100644 --- a/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs +++ b/src/Middleware/ResponseCaching/src/ResponseCachingExtensions.cs @@ -6,8 +6,15 @@ using Microsoft.AspNetCore.ResponseCaching; namespace Microsoft.AspNetCore.Builder { + /// + /// Extension methods for adding the to an application. + /// public static class ResponseCachingExtensions { + /// + /// Adds the for caching HTTP responses. + /// + /// The . public static IApplicationBuilder UseResponseCaching(this IApplicationBuilder app) { if (app == null) diff --git a/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs b/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs index b74d3f47cd..dd75fece9f 100644 --- a/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs +++ b/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs @@ -14,6 +14,9 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.ResponseCaching { + /// + /// Enable HTTP response caching. + /// public class ResponseCachingMiddleware { private static readonly TimeSpan DefaultExpirationTimeSpan = TimeSpan.FromSeconds(10); @@ -29,6 +32,13 @@ namespace Microsoft.AspNetCore.ResponseCaching private readonly IResponseCache _cache; private readonly IResponseCachingKeyProvider _keyProvider; + /// + /// Creates a new . + /// + /// The representing the next middleware in the pipeline. + /// The options for this middleware. + /// The used for logging. + /// The used for creating instances. public ResponseCachingMiddleware( RequestDelegate next, IOptions options, @@ -88,6 +98,11 @@ namespace Microsoft.AspNetCore.ResponseCaching _keyProvider = keyProvider; } + /// + /// Invokes the logic of the middleware. + /// + /// The . + /// A that completes when the middleware has completed processing. public async Task Invoke(HttpContext httpContext) { var context = new ResponseCachingContext(httpContext, _logger); From b6698757a85f9b6d6c63311e64dd6ac9e734ef56 Mon Sep 17 00:00:00 2001 From: Vaughan Reid Date: Thu, 20 Feb 2020 00:03:36 +0200 Subject: [PATCH 10/13] Activity.Baggage values are now be Url decoded in HostingApplicationDiagnostics. (#18948) --- .../Internal/HostingApplicationDiagnostics.cs | 3 +- .../HostingApplicationDiagnosticsTests.cs | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs index 16b36948af..41b93ac083 100644 --- a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs +++ b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; +using System.Web; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; @@ -272,7 +273,7 @@ namespace Microsoft.AspNetCore.Hosting { if (NameValueHeaderValue.TryParse(item, out var baggageItem)) { - activity.AddBaggage(baggageItem.Name.ToString(), baggageItem.Value.ToString()); + activity.AddBaggage(baggageItem.Name.ToString(), HttpUtility.UrlDecode(baggageItem.Value.ToString())); } } } diff --git a/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs b/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs index 385424fa67..341c7c6fa4 100644 --- a/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs +++ b/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs @@ -345,6 +345,35 @@ namespace Microsoft.AspNetCore.Hosting.Tests Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2"); } + [Fact] + public void ActivityBaggageValuesAreUrlDecodedFromHeaders() + { + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); + + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }), + s => + { + if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) + { + return true; + } + return false; + }); + + features.Set(new HttpRequestFeature() + { + Headers = new HeaderDictionary() + { + {"Request-Id", "ParentId1"}, + {"Correlation-Context", "Key1=value1%2F1"} + } + }); + hostingApplication.CreateContext(features); + Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); + Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1/1"); + } + [Fact] public void ActivityTraceParentAndTraceStateFromHeaders() From 474d03c071867dacb40dbdef993d6714b276f558 Mon Sep 17 00:00:00 2001 From: Daniel Abbatt Date: Wed, 19 Feb 2020 19:16:11 +0000 Subject: [PATCH 11/13] Typo in the exception message that's returned Typo in the exception message that's returned Rendererd should be Rendered --- src/Components/Server/src/Circuits/RemoteJSRuntime.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Server/src/Circuits/RemoteJSRuntime.cs b/src/Components/Server/src/Circuits/RemoteJSRuntime.cs index 0ef78bcf0f..1d9205e1ba 100644 --- a/src/Components/Server/src/Circuits/RemoteJSRuntime.cs +++ b/src/Components/Server/src/Circuits/RemoteJSRuntime.cs @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits { throw new InvalidOperationException( "JavaScript interop calls cannot be issued at this time. This is because the component is being " + - $"statically rendererd. When prerendering is enabled, JavaScript interop calls can only be performed " + + $"statically rendered. When prerendering is enabled, JavaScript interop calls can only be performed " + $"during the OnAfterRenderAsync lifecycle method."); } From d597e085185e1c5b271f5b8989f73794c5d71249 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Thu, 20 Feb 2020 20:46:05 +0330 Subject: [PATCH 12/13] Make user-secrets treat unmatched options as arguments (#18256) --- src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs | 2 +- src/Tools/dotnet-user-secrets/test/SecretManagerTests.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs b/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs index 8495b6de9d..7d998f77d7 100644 --- a/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs +++ b/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.SecretManager.Tools public static CommandLineOptions Parse(string[] args, IConsole console) { - var app = new CommandLineApplication() + var app = new CommandLineApplication(treatUnmatchedOptionsAsArguments: true) { Out = console.Out, Error = console.Error, diff --git a/src/Tools/dotnet-user-secrets/test/SecretManagerTests.cs b/src/Tools/dotnet-user-secrets/test/SecretManagerTests.cs index 8d62c065d9..c3633b57be 100644 --- a/src/Tools/dotnet-user-secrets/test/SecretManagerTests.cs +++ b/src/Tools/dotnet-user-secrets/test/SecretManagerTests.cs @@ -93,7 +93,9 @@ namespace Microsoft.Extensions.SecretManager.Tools.Tests new KeyValuePair("key1", Guid.NewGuid().ToString()), new KeyValuePair("Facebook:AppId", Guid.NewGuid().ToString()), new KeyValuePair(@"key-@\/.~123!#$%^&*())-+==", @"key-@\/.~123!#$%^&*())-+=="), - new KeyValuePair("key2", string.Empty) + new KeyValuePair("key2", string.Empty), + new KeyValuePair("-oneDashedKey", "-oneDashedValue"), + new KeyValuePair("--twoDashedKey", "--twoDashedValue") }; var projectPath = _fixture.GetTempSecretProject(); From b3e2dacdaf81846ccae7f56cab556d0526c0b8ce Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 20 Feb 2020 12:46:37 -0800 Subject: [PATCH 13/13] Fix Helix run (#19175) --- .azure/pipelines/helix-test.yml | 8 ++++++++ eng/scripts/RunHelix.ps1 | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.azure/pipelines/helix-test.yml b/.azure/pipelines/helix-test.yml index b1da5574cb..40849ee4d3 100644 --- a/.azure/pipelines/helix-test.yml +++ b/.azure/pipelines/helix-test.yml @@ -11,6 +11,14 @@ pr: include: - '*' +variables: +- ${{ if ne(variables['System.TeamProject'], 'internal') }}: + - name: _UseHelixOpenQueues + value: 'true' +- ${{ if eq(variables['System.TeamProject'], 'internal') }}: + - name: _UseHelixOpenQueues + value: 'false' + jobs: - template: jobs/default-build.yml parameters: diff --git a/eng/scripts/RunHelix.ps1 b/eng/scripts/RunHelix.ps1 index 00bc794f24..177580d3ea 100644 --- a/eng/scripts/RunHelix.ps1 +++ b/eng/scripts/RunHelix.ps1 @@ -38,4 +38,4 @@ $env:BUILD_REPOSITORY_NAME="aspnetcore" $env:SYSTEM_TEAMPROJECT="aspnetcore" $HelixQueues = $HelixQueues -replace ";", "%3B" -dotnet msbuild $Project /t:Helix /p:IsRequiredCheck=true /p:IsHelixDaily=true /p:HelixTargetQueues=$HelixQueues /p:RunQuarantinedTests=$RunQuarantinedTests \ No newline at end of file +dotnet msbuild $Project /t:Helix /p:IsRequiredCheck=true /p:IsHelixDaily=true /p:HelixTargetQueues=$HelixQueues /p:RunQuarantinedTests=$RunQuarantinedTests /p:_UseHelixOpenQueues=true \ No newline at end of file