+
diff --git a/src/Components/test/testassets/TestServer/Controllers/UserController.cs b/src/Components/test/testassets/TestServer/Controllers/UserController.cs
new file mode 100644
index 0000000000..16764e4080
--- /dev/null
+++ b/src/Components/test/testassets/TestServer/Controllers/UserController.cs
@@ -0,0 +1,28 @@
+using System.Linq;
+using BasicTestApp.AuthTest;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Components.TestServer.Controllers
+{
+ [Route("api/[controller]")]
+ public class UserController : Controller
+ {
+ // GET api/user
+ [HttpGet]
+ public ClientSideAuthenticationStateData Get()
+ {
+ // Servers are not expected to expose everything from the server-side ClaimsPrincipal
+ // to the client. It's up to the developer to choose what kind of authentication state
+ // data is needed on the client so it can display suitable options in the UI.
+
+ return new ClientSideAuthenticationStateData
+ {
+ IsAuthenticated = User.Identity.IsAuthenticated,
+ UserName = User.Identity.Name,
+ ExposedClaims = User.Claims
+ .Where(c => c.Type == "test-claim")
+ .ToDictionary(c => c.Type, c => c.Value)
+ };
+ }
+ }
+}
diff --git a/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml b/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml
new file mode 100644
index 0000000000..3f6cbdefd5
--- /dev/null
+++ b/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml
@@ -0,0 +1,72 @@
+@page
+@using Microsoft.AspNetCore.Authentication
+@using System.Security.Claims
+
+
+
+ Authentication
+
+
+ Authentication
+
+ This is a completely fake login mechanism for automated test purposes.
+ It accepts any username, with no password.
+
+
+ Obviously you should not do this in real applications.
+ See also: documentation on configuring a real login system.
+
+
+
+
+
+
+
+
+@functions {
+ public async Task OnGet()
+ {
+ if (Request.Query["signout"] == "true")
+ {
+ await HttpContext.SignOutAsync();
+ return Redirect("Authentication");
+ }
+
+ var username = Request.Query["username"];
+ if (!string.IsNullOrEmpty(username))
+ {
+ var claims = new List
+ {
+ new Claim(ClaimTypes.Name, username),
+ new Claim("test-claim", "Test claim value"),
+ };
+
+ await HttpContext.SignInAsync(
+ new ClaimsPrincipal(new ClaimsIdentity(claims, "FakeAuthenticationType")));
+
+ return Redirect("Authentication");
+ }
+
+ return Page();
+ }
+}
diff --git a/src/Components/test/testassets/TestServer/Startup.cs b/src/Components/test/testassets/TestServer/Startup.cs
index cf7ea69d32..26da1af8e0 100644
--- a/src/Components/test/testassets/TestServer/Startup.cs
+++ b/src/Components/test/testassets/TestServer/Startup.cs
@@ -1,4 +1,5 @@
using BasicTestApp;
+using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Hosting;
@@ -28,6 +29,7 @@ namespace TestServer
options.AddPolicy("AllowAll", _ => { /* Controlled below */ });
});
services.AddServerSideBlazor();
+ services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -50,6 +52,7 @@ namespace TestServer
.AllowCredentials();
});
+ app.UseAuthentication();
// Mount the server-side Blazor app on /subdir
app.Map("/subdir", subdirApp =>
@@ -70,6 +73,7 @@ namespace TestServer
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
+ endpoints.MapRazorPages();
});
// Separately, mount a prerendered server-side Blazor app on /prerendered
diff --git a/src/DataProtection/Extensions/test/DataProtectionProviderTests.cs b/src/DataProtection/Extensions/test/DataProtectionProviderTests.cs
index 9006c778c7..65c542f499 100644
--- a/src/DataProtection/Extensions/test/DataProtectionProviderTests.cs
+++ b/src/DataProtection/Extensions/test/DataProtectionProviderTests.cs
@@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.DataProtection
[ConditionalFact]
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2177", FlakyOn.AzP.Windows)]
[X509StoreIsAvailable(StoreName.My, StoreLocation.CurrentUser)]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public void System_UsesProvidedDirectoryAndCertificate()
{
var filePath = Path.Combine(GetTestFilesPath(), "TestCert.pfx");
@@ -167,7 +167,7 @@ namespace Microsoft.AspNetCore.DataProtection
[ConditionalFact]
[X509StoreIsAvailable(StoreName.My, StoreLocation.CurrentUser)]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public void System_UsesProvidedCertificateNotFromStore()
{
using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
diff --git a/src/DefaultBuilder/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/src/DefaultBuilder/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj
index 416f78e75c..6da74488a4 100644
--- a/src/DefaultBuilder/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj
+++ b/src/DefaultBuilder/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj
@@ -4,7 +4,7 @@
netcoreapp3.0
-
+
false
diff --git a/src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.csproj b/src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.csproj
index 1a9fa78e0f..c2eba6030a 100644
--- a/src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.csproj
+++ b/src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.csproj
@@ -1,10 +1,10 @@
- netcoreapp3.0
+ netstandard2.0
-
-
+
+
diff --git a/src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.netcoreapp3.0.cs b/src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.netstandard2.0.cs
similarity index 100%
rename from src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.netcoreapp3.0.cs
rename to src/Features/JsonPatch/ref/Microsoft.AspNetCore.JsonPatch.netstandard2.0.cs
diff --git a/src/Features/JsonPatch/src/Microsoft.AspNetCore.JsonPatch.csproj b/src/Features/JsonPatch/src/Microsoft.AspNetCore.JsonPatch.csproj
index 63fec7add9..5865069fdd 100644
--- a/src/Features/JsonPatch/src/Microsoft.AspNetCore.JsonPatch.csproj
+++ b/src/Features/JsonPatch/src/Microsoft.AspNetCore.JsonPatch.csproj
@@ -2,7 +2,7 @@
ASP.NET Core support for JSON PATCH.
- netcoreapp3.0
+ netstandard2.0
$(NoWarn);CS1591
true
aspnetcore;json;jsonpatch
diff --git a/src/Hosting/Hosting/test/WebHostTests.cs b/src/Hosting/Hosting/test/WebHostTests.cs
index 5d3e7139c7..3d4a67b076 100644
--- a/src/Hosting/Hosting/test/WebHostTests.cs
+++ b/src/Hosting/Hosting/test/WebHostTests.cs
@@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.Hosting
}
[ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/7291
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/7291")]
public async Task WebHostStopAsyncUsesDefaultTimeoutIfGivenTokenDoesNotFire()
{
var data = new Dictionary
@@ -315,7 +315,7 @@ namespace Microsoft.AspNetCore.Hosting
}
[ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/7291
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/7291")]
public void WebHostApplicationLifetimeEventsOrderedCorrectlyDuringShutdown()
{
using (var host = CreateBuilder()
diff --git a/src/Hosting/test/FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj b/src/Hosting/test/FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj
index 1c92dddbaa..7a273f333d 100644
--- a/src/Hosting/test/FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj
+++ b/src/Hosting/test/FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj
@@ -4,7 +4,7 @@
netcoreapp3.0
-
+
false
diff --git a/src/Hosting/test/FunctionalTests/ShutdownTests.cs b/src/Hosting/test/FunctionalTests/ShutdownTests.cs
index 0d7210cd0d..7e6124e146 100644
--- a/src/Hosting/test/FunctionalTests/ShutdownTests.cs
+++ b/src/Hosting/test/FunctionalTests/ShutdownTests.cs
@@ -49,8 +49,11 @@ namespace Microsoft.AspNetCore.Hosting.FunctionalTests
{
var logger = loggerFactory.CreateLogger(testName);
+// https://github.com/aspnet/AspNetCore/issues/8247
+#pragma warning disable 0618
var applicationPath = Path.Combine(TestPathUtilities.GetSolutionRootDirectory("Hosting"), "test", "testassets",
"Microsoft.AspNetCore.Hosting.TestSites");
+#pragma warning restore 0618
var deploymentParameters = new DeploymentParameters(
applicationPath,
diff --git a/src/Hosting/test/FunctionalTests/WebHostBuilderTests.cs b/src/Hosting/test/FunctionalTests/WebHostBuilderTests.cs
index 88988a779e..216cf1cff9 100644
--- a/src/Hosting/test/FunctionalTests/WebHostBuilderTests.cs
+++ b/src/Hosting/test/FunctionalTests/WebHostBuilderTests.cs
@@ -28,7 +28,10 @@ namespace Microsoft.AspNetCore.Hosting.FunctionalTests
{
var logger = loggerFactory.CreateLogger(nameof(InjectedStartup_DefaultApplicationNameIsEntryAssembly));
+// https://github.com/aspnet/AspNetCore/issues/8247
+#pragma warning disable 0618
var applicationPath = Path.Combine(TestPathUtilities.GetSolutionRootDirectory("Hosting"), "test", "testassets", "IStartupInjectionAssemblyName");
+#pragma warning restore 0618
var deploymentParameters = new DeploymentParameters(variant)
{
diff --git a/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.netcoreapp3.0.cs b/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.netcoreapp3.0.cs
index 6a70682b1a..cae69dd66c 100644
--- a/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.netcoreapp3.0.cs
+++ b/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.netcoreapp3.0.cs
@@ -1,18 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Authorization
-{
- public partial interface IAllowAnonymous
- {
- }
- public partial interface IAuthorizeData
- {
- string AuthenticationSchemes { get; set; }
- string Policy { get; set; }
- string Roles { get; set; }
- }
-}
namespace Microsoft.AspNetCore.Builder
{
public abstract partial class EndpointBuilder
@@ -385,6 +373,13 @@ namespace Microsoft.AspNetCore.Http
public string ToUriComponent() { throw null; }
}
public delegate System.Threading.Tasks.Task RequestDelegate(Microsoft.AspNetCore.Http.HttpContext context);
+ public static partial class RequestTrailerExtensions
+ {
+ public static bool CheckTrailersAvailable(this Microsoft.AspNetCore.Http.HttpRequest request) { throw null; }
+ public static Microsoft.Extensions.Primitives.StringValues GetDeclaredTrailers(this Microsoft.AspNetCore.Http.HttpRequest request) { throw null; }
+ public static Microsoft.Extensions.Primitives.StringValues GetTrailer(this Microsoft.AspNetCore.Http.HttpRequest request, string trailerName) { throw null; }
+ public static bool SupportsTrailers(this Microsoft.AspNetCore.Http.HttpRequest request) { throw null; }
+ }
public static partial class ResponseTrailerExtensions
{
public static void AppendTrailer(this Microsoft.AspNetCore.Http.HttpResponse response, string trailerName, Microsoft.Extensions.Primitives.StringValues trailerValues) { }
diff --git a/src/Http/Http.Abstractions/src/Extensions/RequestTrailerExtensions.cs b/src/Http/Http.Abstractions/src/Extensions/RequestTrailerExtensions.cs
new file mode 100644
index 0000000000..6ffeb2eebc
--- /dev/null
+++ b/src/Http/Http.Abstractions/src/Extensions/RequestTrailerExtensions.cs
@@ -0,0 +1,65 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNetCore.Http.Features;
+using Microsoft.Extensions.Primitives;
+using Microsoft.Net.Http.Headers;
+
+namespace Microsoft.AspNetCore.Http
+{
+ ///
+ /// HttpRequest extensions for working with request trailing headers.
+ ///
+ public static class RequestTrailerExtensions
+ {
+ ///
+ /// Gets the request "Trailer" header that lists which trailers to expect after the body.
+ ///
+ ///
+ ///
+ public static StringValues GetDeclaredTrailers(this HttpRequest request)
+ {
+ return request.Headers.GetCommaSeparatedValues(HeaderNames.Trailer);
+ }
+
+ ///
+ /// Indicates if the request supports receiving trailer headers.
+ ///
+ ///
+ ///
+ public static bool SupportsTrailers(this HttpRequest request)
+ {
+ return request.HttpContext.Features.Get() != null;
+ }
+
+ ///
+ /// Checks if the request supports trailers and they are available to be read now.
+ /// This does not mean that there are any trailers to read.
+ ///
+ ///
+ ///
+ public static bool CheckTrailersAvailable(this HttpRequest request)
+ {
+ return request.HttpContext.Features.Get()?.Available == true;
+ }
+
+ ///
+ /// Gets the requested trailing header from the response. Check
+ /// or a NotSupportedException may be thrown.
+ /// Check or an InvalidOperationException may be thrown.
+ ///
+ ///
+ ///
+ public static StringValues GetTrailer(this HttpRequest request, string trailerName)
+ {
+ var feature = request.HttpContext.Features.Get();
+ if (feature == null)
+ {
+ throw new NotSupportedException("This request does not support trailers.");
+ }
+
+ return feature.Trailers[trailerName];
+ }
+ }
+}
diff --git a/src/Http/Http.Features/ref/Microsoft.AspNetCore.Http.Features.netstandard2.0.cs b/src/Http/Http.Features/ref/Microsoft.AspNetCore.Http.Features.netstandard2.0.cs
index 48f381bb96..8c0f10b5dc 100644
--- a/src/Http/Http.Features/ref/Microsoft.AspNetCore.Http.Features.netstandard2.0.cs
+++ b/src/Http/Http.Features/ref/Microsoft.AspNetCore.Http.Features.netstandard2.0.cs
@@ -195,6 +195,11 @@ namespace Microsoft.AspNetCore.Http.Features
System.Threading.CancellationToken RequestAborted { get; set; }
void Abort();
}
+ public partial interface IHttpRequestTrailersFeature
+ {
+ bool Available { get; }
+ Microsoft.AspNetCore.Http.IHeaderDictionary Trailers { get; }
+ }
public partial interface IHttpResponseFeature
{
System.IO.Stream Body { get; set; }
diff --git a/src/Http/Http.Features/src/IHttpRequestTrailersFeature.cs b/src/Http/Http.Features/src/IHttpRequestTrailersFeature.cs
new file mode 100644
index 0000000000..19706e9e4e
--- /dev/null
+++ b/src/Http/Http.Features/src/IHttpRequestTrailersFeature.cs
@@ -0,0 +1,26 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+
+namespace Microsoft.AspNetCore.Http.Features
+{
+ ///
+ /// This feature exposes HTTP request trailer headers, either for HTTP/1.1 chunked bodies or HTTP/2 trailing headers.
+ ///
+ public interface IHttpRequestTrailersFeature
+ {
+ ///
+ /// Indicates if the are available yet. They may not be available until the
+ /// request body is fully read.
+ ///
+ bool Available { get; }
+
+ ///
+ /// The trailing headers received. This will throw if
+ /// returns false. They may not be available until the request body is fully read. If there are no trailers this will
+ /// return an empty collection.
+ ///
+ IHeaderDictionary Trailers { get; }
+ }
+}
diff --git a/src/Http/Metadata/ref/Microsoft.AspNetCore.Metadata.csproj b/src/Http/Metadata/ref/Microsoft.AspNetCore.Metadata.csproj
new file mode 100644
index 0000000000..5bd3e643f1
--- /dev/null
+++ b/src/Http/Metadata/ref/Microsoft.AspNetCore.Metadata.csproj
@@ -0,0 +1,10 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
diff --git a/src/Http/Metadata/ref/Microsoft.AspNetCore.Metadata.netstandard2.0.cs b/src/Http/Metadata/ref/Microsoft.AspNetCore.Metadata.netstandard2.0.cs
new file mode 100644
index 0000000000..effddb3203
--- /dev/null
+++ b/src/Http/Metadata/ref/Microsoft.AspNetCore.Metadata.netstandard2.0.cs
@@ -0,0 +1,15 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace Microsoft.AspNetCore.Authorization
+{
+ public partial interface IAllowAnonymous
+ {
+ }
+ public partial interface IAuthorizeData
+ {
+ string AuthenticationSchemes { get; set; }
+ string Policy { get; set; }
+ string Roles { get; set; }
+ }
+}
diff --git a/src/Http/Http.Abstractions/src/IAllowAnonymous.cs b/src/Http/Metadata/src/IAllowAnonymous.cs
similarity index 100%
rename from src/Http/Http.Abstractions/src/IAllowAnonymous.cs
rename to src/Http/Metadata/src/IAllowAnonymous.cs
diff --git a/src/Http/Http.Abstractions/src/IAuthorizeData.cs b/src/Http/Metadata/src/IAuthorizeData.cs
similarity index 100%
rename from src/Http/Http.Abstractions/src/IAuthorizeData.cs
rename to src/Http/Metadata/src/IAuthorizeData.cs
diff --git a/src/Http/Metadata/src/Microsoft.AspNetCore.Metadata.csproj b/src/Http/Metadata/src/Microsoft.AspNetCore.Metadata.csproj
new file mode 100644
index 0000000000..4c2b8fed22
--- /dev/null
+++ b/src/Http/Metadata/src/Microsoft.AspNetCore.Metadata.csproj
@@ -0,0 +1,12 @@
+
+
+
+ ASP.NET Core metadata.
+ netstandard2.0
+ true
+ $(NoWarn);CS1591
+ true
+ aspnetcore
+
+
+
diff --git a/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.csproj b/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.csproj
index 4771b24dcf..a68d86a042 100644
--- a/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.csproj
+++ b/src/Http/Routing/ref/Microsoft.AspNetCore.Routing.csproj
@@ -5,6 +5,7 @@
+
diff --git a/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj b/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj
index b78218944f..70f62b2cfe 100644
--- a/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj
+++ b/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj
@@ -26,6 +26,7 @@ Microsoft.AspNetCore.Routing.RouteCollection
+
diff --git a/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/ConfigureSigningCredentialsTests.cs b/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/ConfigureSigningCredentialsTests.cs
index 40a22ff1a7..0fb9d68e00 100644
--- a/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/ConfigureSigningCredentialsTests.cs
+++ b/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/ConfigureSigningCredentialsTests.cs
@@ -22,8 +22,8 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer
UnsafeEphemeralKeySet : (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? X509KeyStorageFlags.PersistKeySet :
X509KeyStorageFlags.DefaultKeySet);
- [ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [ConditionalFact]
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
[FrameworkSkipCondition(RuntimeFrameworks.CLR)]
public void Configure_AddsDevelopmentKeyFromConfiguration()
{
@@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer
}
[ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public void Configure_LoadsPfxCertificateCredentialFromConfiguration()
{
// Arrange
@@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer
}
[ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public void Configure_LoadsCertificateStoreCertificateCredentialFromConfiguration()
{
try
diff --git a/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/SigningKeysLoaderTests.cs b/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/SigningKeysLoaderTests.cs
index 8551f9ccae..20bd91c88f 100644
--- a/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/SigningKeysLoaderTests.cs
+++ b/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/SigningKeysLoaderTests.cs
@@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
[Fact]
public void LoadFromFile_ThrowsIfFileDoesNotExist()
{
- // Arrange, Act & Assert
+ // Arrange, Act & Assert
var exception = Assert.Throws(() => SigningKeysLoader.LoadFromFile("./nonexisting.pfx", "", DefaultFlags));
Assert.Equal($"There was an error loading the certificate. The file './nonexisting.pfx' was not found.", exception.Message);
}
@@ -58,8 +58,8 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
Assert.Equal("Couldn't find a valid certificate with subject 'Invalid' on the 'CurrentUser\\My'", exception.Message);
}
- [ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [ConditionalFact]
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public static void LoadFromStoreCert_SkipsCertificatesNotYetValid()
{
try
@@ -81,8 +81,8 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
}
}
- [ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [ConditionalFact]
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public static void LoadFromStoreCert_PrefersCertificatesCloserToExpirationDate()
{
try
@@ -104,8 +104,8 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
}
}
- [ConditionalFact]
- [SkipOnHelix] // https://github.com/aspnet/AspNetCore/issues/6720
+ [ConditionalFact]
+ [SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/6720")]
public static void LoadFromStoreCert_SkipsExpiredCertificates()
{
try
diff --git a/src/Identity/UI/src/wwwroot/V4/Identity/css/site.css b/src/Identity/UI/src/wwwroot/V4/Identity/css/site.css
index e1ca50bc9f..52889ec4d5 100644
--- a/src/Identity/UI/src/wwwroot/V4/Identity/css/site.css
+++ b/src/Identity/UI/src/wwwroot/V4/Identity/css/site.css
@@ -7,6 +7,23 @@ a.navbar-brand {
word-break: break-all;
}
+/* Provide sufficient contrast against white background */
+a {
+ color: #0366d6;
+}
+
+.btn-primary {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
+
+.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
+
/* Sticky footer styles
-------------------------------------------------- */
html {
@@ -59,7 +76,5 @@ body {
width: 100%;
overflow: scroll;
white-space: nowrap;
- /* Set the fixed height of the footer here */
- height: 60px;
line-height: 60px; /* Vertically center the text there */
}
diff --git a/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs b/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs
index 14ae5b2db4..f3915ed44e 100644
--- a/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs
+++ b/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs
@@ -50,8 +50,7 @@ namespace Identity.DefaultUI.WebSite
.AddRoles()
.AddEntityFrameworkStores();
- services.AddMvc()
- .AddNewtonsoftJson();
+ services.AddMvc();
services.AddSingleton();
}
diff --git a/src/Installers/Windows/SharedFrameworkBundle/Bundle.wxs b/src/Installers/Windows/SharedFrameworkBundle/Bundle.wxs
index 4880a599b7..ecdb8d7264 100644
--- a/src/Installers/Windows/SharedFrameworkBundle/Bundle.wxs
+++ b/src/Installers/Windows/SharedFrameworkBundle/Bundle.wxs
@@ -26,7 +26,7 @@
-
+
diff --git a/src/Installers/Windows/WindowsHostingBundle/Bundle.wxs b/src/Installers/Windows/WindowsHostingBundle/Bundle.wxs
index 95897534b7..8fd846a61a 100644
--- a/src/Installers/Windows/WindowsHostingBundle/Bundle.wxs
+++ b/src/Installers/Windows/WindowsHostingBundle/Bundle.wxs
@@ -21,7 +21,7 @@
-
+
diff --git a/src/Middleware/CORS/test/FunctionalTests/CORS.FunctionalTests.csproj b/src/Middleware/CORS/test/FunctionalTests/CORS.FunctionalTests.csproj
index 8bb04bbf54..1c0e5a12a1 100644
--- a/src/Middleware/CORS/test/FunctionalTests/CORS.FunctionalTests.csproj
+++ b/src/Middleware/CORS/test/FunctionalTests/CORS.FunctionalTests.csproj
@@ -6,7 +6,7 @@
$(DefaultItemExcludes);node_modules\**\*
-
+
false
diff --git a/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs b/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs
index 717f67a07f..2990bd53a9 100644
--- a/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs
+++ b/src/Middleware/CORS/test/FunctionalTests/CorsMiddlewareFunctionalTest.cs
@@ -68,7 +68,10 @@ namespace FunctionalTests
private static async Task CreateDeployments(ILoggerFactory loggerFactory, string startup)
{
+ // https://github.com/aspnet/AspNetCore/issues/7990
+#pragma warning disable 0618
var solutionPath = TestPathUtilities.GetSolutionRootDirectory("Middleware");
+#pragma warning restore 0618
var configuration =
#if RELEASE
diff --git a/src/Middleware/Middleware.sln b/src/Middleware/Middleware.sln
index 5f16259900..a02c8c40a8 100644
--- a/src/Middleware/Middleware.sln
+++ b/src/Middleware/Middleware.sln
@@ -283,6 +283,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HeaderPropagationSample", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IIS", "..\Servers\IIS\IIS\src\Microsoft.AspNetCore.Server.IIS.csproj", "{B9BE1823-B555-4AAB-AEBC-C8C3F48C8861}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RequestThrottling", "RequestThrottling", "{8C9AA8A2-9D1F-4450-9F8D-56BAB6F3D343}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RequestThrottlingSample", "RequestThrottling\sample\RequestThrottlingSample.csproj", "{6720919C-0DEA-49E1-90DC-F1883F7919CD}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RequestThrottling", "RequestThrottling\src\Microsoft.AspNetCore.RequestThrottling.csproj", "{4CE2384D-6B88-4824-ADD1-4183D180FEFF}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RequestThrottling.Tests", "RequestThrottling\test\Microsoft.AspNetCore.RequestThrottling.Tests.csproj", "{353AA2B0-1013-486C-B5BD-9379385CA403}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1541,6 +1549,42 @@ Global
{B9BE1823-B555-4AAB-AEBC-C8C3F48C8861}.Release|x64.Build.0 = Release|Any CPU
{B9BE1823-B555-4AAB-AEBC-C8C3F48C8861}.Release|x86.ActiveCfg = Release|Any CPU
{B9BE1823-B555-4AAB-AEBC-C8C3F48C8861}.Release|x86.Build.0 = Release|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Debug|x64.Build.0 = Debug|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Debug|x86.Build.0 = Debug|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Release|x64.ActiveCfg = Release|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Release|x64.Build.0 = Release|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Release|x86.ActiveCfg = Release|Any CPU
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD}.Release|x86.Build.0 = Release|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Debug|x64.Build.0 = Debug|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Debug|x86.Build.0 = Debug|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Release|x64.ActiveCfg = Release|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Release|x64.Build.0 = Release|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Release|x86.ActiveCfg = Release|Any CPU
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF}.Release|x86.Build.0 = Release|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Debug|x64.Build.0 = Debug|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Debug|x86.Build.0 = Debug|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Release|Any CPU.Build.0 = Release|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Release|x64.ActiveCfg = Release|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Release|x64.Build.0 = Release|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Release|x86.ActiveCfg = Release|Any CPU
+ {353AA2B0-1013-486C-B5BD-9379385CA403}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1663,6 +1707,9 @@ Global
{179A159B-87EA-4353-BE92-4FB6CC05BC7D} = {0437D207-864E-429C-92B4-9D08D290188C}
{CDE2E736-A034-4748-98C4-0DEDAAC8063D} = {179A159B-87EA-4353-BE92-4FB6CC05BC7D}
{B9BE1823-B555-4AAB-AEBC-C8C3F48C8861} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
+ {6720919C-0DEA-49E1-90DC-F1883F7919CD} = {8C9AA8A2-9D1F-4450-9F8D-56BAB6F3D343}
+ {4CE2384D-6B88-4824-ADD1-4183D180FEFF} = {8C9AA8A2-9D1F-4450-9F8D-56BAB6F3D343}
+ {353AA2B0-1013-486C-B5BD-9379385CA403} = {8C9AA8A2-9D1F-4450-9F8D-56BAB6F3D343}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA}
diff --git a/src/Middleware/RequestThrottling/RequestThrottling.slnf b/src/Middleware/RequestThrottling/RequestThrottling.slnf
new file mode 100644
index 0000000000..d434fbc862
--- /dev/null
+++ b/src/Middleware/RequestThrottling/RequestThrottling.slnf
@@ -0,0 +1,25 @@
+{
+ "solution": {
+ "path": "..\\Middleware.sln",
+ "projects": [
+ "..\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
+ "..\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj",
+ "..\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj",
+ "..\\Http\\Http.Abstractions\\src\\Microsoft.AspNetCore.Http.Abstractions.csproj",
+ "..\\Http\\Http.Extensions\\src\\Microsoft.AspNetCore.Http.Extensions.csproj",
+ "..\\Http\\Http.Features\\src\\Microsoft.AspNetCore.Http.Features.csproj",
+ "..\\Http\\WebUtilities\\src\\Microsoft.AspNetCore.WebUtilities.csproj",
+ "..\\Servers\\Connections.Abstractions\\src\\Microsoft.AspNetCore.Connections.Abstractions.csproj",
+ "..\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj",
+ "..\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj",
+ "..\\Servers\\Kestrel\\Transport.Abstractions\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.csproj",
+ "..\\Servers\\Kestrel\\Transport.Sockets\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj",
+ "..\\http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
+ "..\\http\\http\\src\\Microsoft.AspNetCore.Http.csproj",
+ "HttpsPolicy\\src\\Microsoft.AspNetCore.HttpsPolicy.csproj",
+ "RequestThrottling\\sample\\RequestThrottlingSample.csproj",
+ "RequestThrottling\\src\\Microsoft.AspNetCore.RequestThrottling.csproj",
+ "RequestThrottling\\test\\Microsoft.AspNetCore.RequestThrottling.Tests.csproj"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/src/Middleware/RequestThrottling/ref/Microsoft.AspNetCore.RequestThrottling.csproj b/src/Middleware/RequestThrottling/ref/Microsoft.AspNetCore.RequestThrottling.csproj
new file mode 100644
index 0000000000..0a1bcdd0b9
--- /dev/null
+++ b/src/Middleware/RequestThrottling/ref/Microsoft.AspNetCore.RequestThrottling.csproj
@@ -0,0 +1,10 @@
+
+
+
+ netcoreapp3.0
+
+
+
+
+
+
diff --git a/src/Middleware/RequestThrottling/ref/Microsoft.AspNetCore.RequestThrottling.netcoreapp3.0.cs b/src/Middleware/RequestThrottling/ref/Microsoft.AspNetCore.RequestThrottling.netcoreapp3.0.cs
new file mode 100644
index 0000000000..618082bc4a
--- /dev/null
+++ b/src/Middleware/RequestThrottling/ref/Microsoft.AspNetCore.RequestThrottling.netcoreapp3.0.cs
@@ -0,0 +1,3 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
diff --git a/src/Middleware/RequestThrottling/sample/RequestThrottlingSample.csproj b/src/Middleware/RequestThrottling/sample/RequestThrottlingSample.csproj
new file mode 100644
index 0000000000..0f80e6516a
--- /dev/null
+++ b/src/Middleware/RequestThrottling/sample/RequestThrottlingSample.csproj
@@ -0,0 +1,13 @@
+
+
+
+ netcoreapp3.0
+
+
+
+
+
+
+
+
+
diff --git a/src/Middleware/RequestThrottling/sample/Startup.cs b/src/Middleware/RequestThrottling/sample/Startup.cs
new file mode 100644
index 0000000000..95a94be56d
--- /dev/null
+++ b/src/Middleware/RequestThrottling/sample/Startup.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace RequestThrottlingSample
+{
+ public class Startup
+ {
+ // This method gets called by the runtime. Use this method to add services to the container.
+ // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
+ public void ConfigureServices(IServiceCollection services)
+ {
+ }
+
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment environment)
+ {
+ app.Run(async context =>
+ {
+ await context.Response.WriteAsync("Hello world!");
+ });
+ }
+
+ // Entry point for the application.
+ public static void Main(string[] args)
+ {
+ var host = new WebHostBuilder()
+ .UseKestrel()
+ .UseContentRoot(Directory.GetCurrentDirectory()) // for the cert file
+ .ConfigureLogging(factory =>
+ {
+ factory.SetMinimumLevel(LogLevel.Debug);
+ factory.AddConsole();
+ })
+ .UseStartup()
+ .Build();
+
+ host.Run();
+ }
+ }
+}
diff --git a/src/Middleware/RequestThrottling/src/Microsoft.AspNetCore.RequestThrottling.csproj b/src/Middleware/RequestThrottling/src/Microsoft.AspNetCore.RequestThrottling.csproj
new file mode 100644
index 0000000000..5014e9cec5
--- /dev/null
+++ b/src/Middleware/RequestThrottling/src/Microsoft.AspNetCore.RequestThrottling.csproj
@@ -0,0 +1,10 @@
+
+
+
+ ASP.NET Core middleware for queuing incoming HTTP requests, to avoid threadpool starvation.
+ netcoreapp3.0
+ true
+ aspnetcore;queue;queuing
+
+
+
diff --git a/src/Middleware/RequestThrottling/src/Properties/AssemblyInfo.cs b/src/Middleware/RequestThrottling/src/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..1dcaedfaa6
--- /dev/null
+++ b/src/Middleware/RequestThrottling/src/Properties/AssemblyInfo.cs
@@ -0,0 +1,6 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Microsoft.AspNetCore.RequestThrottling.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
diff --git a/src/Middleware/RequestThrottling/src/SemaphoreWrapper.cs b/src/Middleware/RequestThrottling/src/SemaphoreWrapper.cs
new file mode 100644
index 0000000000..4c79b94777
--- /dev/null
+++ b/src/Middleware/RequestThrottling/src/SemaphoreWrapper.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Microsoft.AspNetCore.RequestThrottling
+{
+ internal class SemaphoreWrapper : IDisposable
+ {
+ private SemaphoreSlim _semaphore;
+
+ public SemaphoreWrapper(int queueLength)
+ {
+ _semaphore = new SemaphoreSlim(queueLength);
+ }
+
+ public Task EnterQueue()
+ {
+ return _semaphore.WaitAsync();
+ }
+
+ public void LeaveQueue()
+ {
+ _semaphore.Release();
+ }
+
+ public int Count
+ {
+ get => _semaphore.CurrentCount;
+ }
+
+ public void Dispose()
+ {
+ _semaphore.Dispose();
+ }
+ }
+}
diff --git a/src/Middleware/RequestThrottling/test/Microsoft.AspNetCore.RequestThrottling.Tests.csproj b/src/Middleware/RequestThrottling/test/Microsoft.AspNetCore.RequestThrottling.Tests.csproj
new file mode 100644
index 0000000000..8c0dd8e989
--- /dev/null
+++ b/src/Middleware/RequestThrottling/test/Microsoft.AspNetCore.RequestThrottling.Tests.csproj
@@ -0,0 +1,10 @@
+
+
+
+ netcoreapp3.0
+
+
+
+
+
+
diff --git a/src/Middleware/RequestThrottling/test/SemaphoreWrapperTests.cs b/src/Middleware/RequestThrottling/test/SemaphoreWrapperTests.cs
new file mode 100644
index 0000000000..b5cdfce18f
--- /dev/null
+++ b/src/Middleware/RequestThrottling/test/SemaphoreWrapperTests.cs
@@ -0,0 +1,66 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Xunit;
+using System.Threading;
+using System.Threading.Tasks;
+using System;
+using System.Runtime.CompilerServices;
+using Microsoft.AspNetCore.Testing;
+
+namespace Microsoft.AspNetCore.RequestThrottling.Tests
+{
+ public class SemaphoreWrapperTests
+ {
+ [Fact]
+ public async Task TracksQueueLength()
+ {
+ using var s = new SemaphoreWrapper(1);
+ Assert.Equal(1, s.Count);
+
+ await s.EnterQueue().OrTimeout();
+ Assert.Equal(0, s.Count);
+
+ s.LeaveQueue();
+ Assert.Equal(1, s.Count);
+ }
+
+ [Fact]
+ public void DoesNotWaitIfSpaceAvailible()
+ {
+ using var s = new SemaphoreWrapper(2);
+
+ var t1 = s.EnterQueue();
+ Assert.True(t1.IsCompleted);
+
+ var t2 = s.EnterQueue();
+ Assert.True(t2.IsCompleted);
+
+ var t3 = s.EnterQueue();
+ Assert.False(t3.IsCompleted);
+ }
+
+ [Fact]
+ public async Task WaitsIfNoSpaceAvailible()
+ {
+ using var s = new SemaphoreWrapper(1);
+ await s.EnterQueue().OrTimeout();
+
+ var waitingTask = s.EnterQueue();
+ Assert.False(waitingTask.IsCompleted);
+
+ s.LeaveQueue();
+ await waitingTask.OrTimeout();
+ }
+
+ [Fact]
+ public async Task IsEncapsulated()
+ {
+ using var s1 = new SemaphoreWrapper(1);
+ using var s2 = new SemaphoreWrapper(1);
+
+ await s1.EnterQueue().OrTimeout();
+ await s2.EnterQueue().OrTimeout();
+ }
+ }
+}
diff --git a/src/Middleware/RequestThrottling/test/TaskExtensions.cs b/src/Middleware/RequestThrottling/test/TaskExtensions.cs
new file mode 100644
index 0000000000..52ec0c4303
--- /dev/null
+++ b/src/Middleware/RequestThrottling/test/TaskExtensions.cs
@@ -0,0 +1,69 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using Microsoft.AspNetCore.Testing;
+
+namespace System.Threading.Tasks
+{
+#if TESTUTILS
+ public
+#else
+ internal
+#endif
+ static class TaskExtensions
+ {
+ private const int DefaultTimeout = 30 * 1000;
+
+ public static Task OrTimeout(this Task task, int milliseconds = DefaultTimeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null)
+ {
+ return OrTimeout(task, new TimeSpan(0, 0, 0, 0, milliseconds), memberName, filePath, lineNumber);
+ }
+
+ public static Task OrTimeout(this Task task, TimeSpan timeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null)
+ {
+ return task.TimeoutAfter(timeout, filePath, lineNumber ?? 0);
+ }
+
+ public static Task OrTimeout(this ValueTask task, int milliseconds = DefaultTimeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null) =>
+ OrTimeout(task, new TimeSpan(0, 0, 0, 0, milliseconds), memberName, filePath, lineNumber);
+
+ public static Task OrTimeout(this ValueTask task, TimeSpan timeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null) =>
+ task.AsTask().OrTimeout(timeout, memberName, filePath, lineNumber);
+
+ public static Task OrTimeout(this Task task, int milliseconds = DefaultTimeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null)
+ {
+ return OrTimeout(task, new TimeSpan(0, 0, 0, 0, milliseconds), memberName, filePath, lineNumber);
+ }
+
+ public static Task OrTimeout(this Task task, TimeSpan timeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null)
+ {
+ return task.TimeoutAfter(timeout, filePath, lineNumber ?? 0);
+ }
+
+ public static async Task OrThrowIfOtherFails(this Task task, Task otherTask)
+ {
+ var completed = await Task.WhenAny(task, otherTask);
+ if (completed == otherTask && otherTask.IsFaulted)
+ {
+ // Manifest the exception
+ otherTask.GetAwaiter().GetResult();
+ throw new Exception("Unreachable code");
+ }
+ else
+ {
+ // Await the task we were asked to await. Either it's finished, or the otherTask finished successfully, and it's not our job to check that
+ await task;
+ }
+ }
+
+ public static async Task OrThrowIfOtherFails(this Task task, Task otherTask)
+ {
+ await OrThrowIfOtherFails((Task)task, otherTask);
+
+ // If we get here, 'task' is finished and succeeded.
+ return task.GetAwaiter().GetResult();
+ }
+ }
+}
diff --git a/src/Middleware/build.cmd b/src/Middleware/build.cmd
new file mode 100644
index 0000000000..033fe6f614
--- /dev/null
+++ b/src/Middleware/build.cmd
@@ -0,0 +1,3 @@
+@ECHO OFF
+SET RepoRoot=%~dp0..\..
+%RepoRoot%\build.cmd -projects %~dp0\**\*.*proj %*
diff --git a/src/MusicStore/test/MusicStore.E2ETests/Common/Helpers.cs b/src/MusicStore/test/MusicStore.E2ETests/Common/Helpers.cs
index 954cb9dea5..eb761e21a5 100644
--- a/src/MusicStore/test/MusicStore.E2ETests/Common/Helpers.cs
+++ b/src/MusicStore/test/MusicStore.E2ETests/Common/Helpers.cs
@@ -9,7 +9,10 @@ namespace E2ETests
{
public static string GetApplicationPath()
{
+ // https://github.com/aspnet/AspNetCore/issues/8343
+#pragma warning disable 0618
var solutionDirectory = TestPathUtilities.GetSolutionRootDirectory("MusicStore");
+#pragma warning restore 0618
return Path.GetFullPath(Path.Combine(solutionDirectory, "samples", "MusicStore"));
}
diff --git a/src/MusicStore/test/MusicStore.E2ETests/MusicStore.E2ETests.csproj b/src/MusicStore/test/MusicStore.E2ETests/MusicStore.E2ETests.csproj
index 5a2d81e394..affbb20ef3 100644
--- a/src/MusicStore/test/MusicStore.E2ETests/MusicStore.E2ETests.csproj
+++ b/src/MusicStore/test/MusicStore.E2ETests/MusicStore.E2ETests.csproj
@@ -9,7 +9,7 @@
$(WarningsNotAsErrors);xUnit1004
$(NoWarn);NU1605
-
+
false
false
false
diff --git a/src/Mvc/Mvc.Analyzers/src/AttributesShouldNotBeAppliedToPageModelAnalyzer.cs b/src/Mvc/Mvc.Analyzers/src/AttributesShouldNotBeAppliedToPageModelAnalyzer.cs
index 4dc7b6c85d..ee91bde64e 100644
--- a/src/Mvc/Mvc.Analyzers/src/AttributesShouldNotBeAppliedToPageModelAnalyzer.cs
+++ b/src/Mvc/Mvc.Analyzers/src/AttributesShouldNotBeAppliedToPageModelAnalyzer.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
@@ -122,7 +121,7 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
}
}
- private static AttributeData GetAttribute(ISymbol symbol, INamedTypeSymbol attributeType)
+ private static AttributeData? GetAttribute(ISymbol symbol, INamedTypeSymbol attributeType)
{
foreach (var attribute in symbol.GetAttributes())
{
diff --git a/src/Mvc/Mvc.Analyzers/src/CodeAnalysisExtensions.cs b/src/Mvc/Mvc.Analyzers/src/CodeAnalysisExtensions.cs
index 72da1b1f4c..50508ab63d 100644
--- a/src/Mvc/Mvc.Analyzers/src/CodeAnalysisExtensions.cs
+++ b/src/Mvc/Mvc.Analyzers/src/CodeAnalysisExtensions.cs
@@ -31,9 +31,10 @@ namespace Microsoft.CodeAnalysis
Debug.Assert(methodSymbol != null);
Debug.Assert(attribute != null);
- while (methodSymbol != null)
+ IMethodSymbol? current = methodSymbol;
+ while (current != null)
{
- foreach (var attributeData in GetAttributes(methodSymbol, attribute))
+ foreach (var attributeData in GetAttributes(current, attribute))
{
yield return attributeData;
}
@@ -43,7 +44,7 @@ namespace Microsoft.CodeAnalysis
break;
}
- methodSymbol = methodSymbol.IsOverride ? methodSymbol.OverriddenMethod : null;
+ current = current.IsOverride ? current.OverriddenMethod : null;
}
}
@@ -76,14 +77,15 @@ namespace Microsoft.CodeAnalysis
return HasAttribute(propertySymbol, attribute);
}
- while (propertySymbol != null)
+ IPropertySymbol? current = propertySymbol;
+ while (current != null)
{
- if (propertySymbol.HasAttribute(attribute))
+ if (current.HasAttribute(attribute))
{
return true;
}
- propertySymbol = propertySymbol.IsOverride ? propertySymbol.OverriddenProperty : null;
+ current = current.IsOverride ? current.OverriddenProperty : null;
}
return false;
diff --git a/src/Mvc/Mvc.Analyzers/src/Microsoft.AspNetCore.Mvc.Analyzers.csproj b/src/Mvc/Mvc.Analyzers/src/Microsoft.AspNetCore.Mvc.Analyzers.csproj
index 1e92917e80..d3422ae192 100644
--- a/src/Mvc/Mvc.Analyzers/src/Microsoft.AspNetCore.Mvc.Analyzers.csproj
+++ b/src/Mvc/Mvc.Analyzers/src/Microsoft.AspNetCore.Mvc.Analyzers.csproj
@@ -9,6 +9,8 @@
false
false
$(MSBuildProjectName).nuspec
+ enable
+ enable