diff --git a/docs/BuildFromSource.md b/docs/BuildFromSource.md index 815480a48f9f..4d93c4d7e78b 100644 --- a/docs/BuildFromSource.md +++ b/docs/BuildFromSource.md @@ -359,7 +359,7 @@ Common properties include: ### Resx files -If you need to make changes to a .resx file, run `dotnet msbuild t:/Resgen `. This will update the generated C#. +After making changes to a .resx file, the updated strings and accessor methods will automatically be included in the output assembly when the project is next built. ## Step 5: Use the result of your build diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 19efe1e27488..1b73b6a77c79 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -9,37 +9,37 @@ --> - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 - + https://github.com/dotnet/efcore - 4e3ce4e13036eaeac700b2a08faa0d45270beb6e + d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814 https://github.com/dotnet/runtime diff --git a/eng/Versions.props b/eng/Versions.props index cdb1a28c0dc7..525f59d05302 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -129,14 +129,14 @@ 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 - 6.0.0-rc.1.21372.1 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 + 6.0.0-rc.1.21372.2 6.0.0-beta.21366.1 6.0.0-beta.21366.1 diff --git a/src/Http/Http.Abstractions/src/Extensions/MapMiddleware.cs b/src/Http/Http.Abstractions/src/Extensions/MapMiddleware.cs index 2763dc59a2b4..35b25f40e62b 100644 --- a/src/Http/Http.Abstractions/src/Extensions/MapMiddleware.cs +++ b/src/Http/Http.Abstractions/src/Extensions/MapMiddleware.cs @@ -46,7 +46,7 @@ public MapMiddleware(RequestDelegate next, MapOptions options) /// /// The for the current request. /// A task that represents the execution of this middleware. - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (context == null) { @@ -55,32 +55,32 @@ public async Task Invoke(HttpContext context) if (context.Request.Path.StartsWithSegments(_options.PathMatch, out var matchedPath, out var remainingPath)) { - var path = context.Request.Path; - var pathBase = context.Request.PathBase; - if (!_options.PreserveMatchedPathSegment) { - // Update the path - context.Request.PathBase = pathBase.Add(matchedPath); - context.Request.Path = remainingPath; + return InvokeCore(context, matchedPath, remainingPath); } + return _options.Branch!(context); + } + return _next(context); + } - try - { - await _options.Branch!(context); - } - finally - { - if (!_options.PreserveMatchedPathSegment) - { - context.Request.PathBase = pathBase; - context.Request.Path = path; - } - } + private async Task InvokeCore(HttpContext context, string matchedPath, string remainingPath) + { + var path = context.Request.Path; + var pathBase = context.Request.PathBase; + + // Update the path + context.Request.PathBase = pathBase.Add(matchedPath); + context.Request.Path = remainingPath; + + try + { + await _options.Branch!(context); } - else + finally { - await _next(context); + context.Request.PathBase = pathBase; + context.Request.Path = path; } } } diff --git a/src/Http/Http.Abstractions/src/Extensions/MapWhenMiddleware.cs b/src/Http/Http.Abstractions/src/Extensions/MapWhenMiddleware.cs index 465f2b8bfa06..97640556968c 100644 --- a/src/Http/Http.Abstractions/src/Extensions/MapWhenMiddleware.cs +++ b/src/Http/Http.Abstractions/src/Extensions/MapWhenMiddleware.cs @@ -51,7 +51,7 @@ public MapWhenMiddleware(RequestDelegate next, MapWhenOptions options) /// /// The for the current request. /// A task that represents the execution of this middleware. - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (context == null) { @@ -60,12 +60,9 @@ public async Task Invoke(HttpContext context) if (_options.Predicate!(context)) { - await _options.Branch!(context); - } - else - { - await _next(context); + return _options.Branch!(context); } + return _next(context); } } } diff --git a/src/Http/Http.Abstractions/src/Extensions/UsePathBaseMiddleware.cs b/src/Http/Http.Abstractions/src/Extensions/UsePathBaseMiddleware.cs index 7cd4f1217ed1..34ffc5738d40 100644 --- a/src/Http/Http.Abstractions/src/Extensions/UsePathBaseMiddleware.cs +++ b/src/Http/Http.Abstractions/src/Extensions/UsePathBaseMiddleware.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -41,37 +41,36 @@ public UsePathBaseMiddleware(RequestDelegate next, PathString pathBase) /// /// The for the current request. /// A task that represents the execution of this middleware. - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } - PathString matchedPath; - PathString remainingPath; - - if (context.Request.Path.StartsWithSegments(_pathBase, out matchedPath, out remainingPath)) + if (context.Request.Path.StartsWithSegments(_pathBase, out var matchedPath, out var remainingPath)) { - var originalPath = context.Request.Path; - var originalPathBase = context.Request.PathBase; - context.Request.Path = remainingPath; - context.Request.PathBase = originalPathBase.Add(matchedPath); - - try - { - await _next(context); - } - finally - { - context.Request.Path = originalPath; - context.Request.PathBase = originalPathBase; - } + return InvokeCore(context, matchedPath, remainingPath); } - else + return _next(context); + } + + private async Task InvokeCore(HttpContext context, string matchedPath, string remainingPath) + { + var originalPath = context.Request.Path; + var originalPathBase = context.Request.PathBase; + context.Request.Path = remainingPath; + context.Request.PathBase = originalPathBase.Add(matchedPath); + + try { await _next(context); } + finally + { + context.Request.Path = originalPath; + context.Request.PathBase = originalPathBase; + } } } -} \ No newline at end of file +} diff --git a/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs b/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs index 1c6b0f1f0200..0fc79278852e 100644 --- a/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs +++ b/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs @@ -59,7 +59,7 @@ public MigrationsEndPointMiddleware( /// /// The context for the current request. /// A task that represents the asynchronous operation. - public virtual async Task Invoke(HttpContext context) + public virtual Task Invoke(HttpContext context) { if (context == null) { @@ -68,39 +68,41 @@ public virtual async Task Invoke(HttpContext context) if (context.Request.Path.Equals(_options.Path)) { - _logger.RequestPathMatched(context.Request.Path); + return InvokeCore(context); + } + return _next(context); + } - var db = await GetDbContext(context, _logger); + private async Task InvokeCore(HttpContext context) + { + _logger.RequestPathMatched(context.Request.Path); - if (db != null) + var db = await GetDbContext(context, _logger); + + if (db != null) + { + var dbName = db.GetType().FullName!; + try { - var dbName = db.GetType().FullName!; - try - { - _logger.ApplyingMigrations(dbName); + _logger.ApplyingMigrations(dbName); - await db.Database.MigrateAsync(); + await db.Database.MigrateAsync(); - context.Response.StatusCode = (int)HttpStatusCode.NoContent; - context.Response.Headers.Add("Pragma", new[] { "no-cache" }); - context.Response.Headers.Add("Cache-Control", new[] { "no-cache,no-store" }); + context.Response.StatusCode = (int)HttpStatusCode.NoContent; + context.Response.Headers.Add("Pragma", new[] { "no-cache" }); + context.Response.Headers.Add("Cache-Control", new[] { "no-cache,no-store" }); - _logger.MigrationsApplied(dbName); - } - catch (Exception ex) - { - var message = Strings.FormatMigrationsEndPointMiddleware_Exception(dbName) + ex; + _logger.MigrationsApplied(dbName); + } + catch (Exception ex) + { + var message = Strings.FormatMigrationsEndPointMiddleware_Exception(dbName) + ex; - _logger.MigrationsEndPointMiddlewareException(dbName, ex); + _logger.MigrationsEndPointMiddlewareException(dbName, ex); - throw new InvalidOperationException(message, ex); - } + throw new InvalidOperationException(message, ex); } } - else - { - await _next(context); - } } private static async Task GetDbContext(HttpContext context, ILogger logger) diff --git a/src/Middleware/HttpOverrides/src/HttpMethodOverrideMiddleware.cs b/src/Middleware/HttpOverrides/src/HttpMethodOverrideMiddleware.cs index 4ac89937932a..f4fc3436548a 100644 --- a/src/Middleware/HttpOverrides/src/HttpMethodOverrideMiddleware.cs +++ b/src/Middleware/HttpOverrides/src/HttpMethodOverrideMiddleware.cs @@ -41,7 +41,7 @@ public HttpMethodOverrideMiddleware(RequestDelegate next, IOptions /// The for the current request. - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (HttpMethods.IsPost(context.Request.Method)) { @@ -49,12 +49,7 @@ public async Task Invoke(HttpContext context) { if (context.Request.HasFormContentType) { - var form = await context.Request.ReadFormAsync(); - var methodType = form[_options.FormFieldName]; - if (!string.IsNullOrEmpty(methodType)) - { - context.Request.Method = methodType; - } + return InvokeCore(context); } } else @@ -66,6 +61,17 @@ public async Task Invoke(HttpContext context) } } } + return _next(context); + } + + private async Task InvokeCore(HttpContext context) + { + var form = await context.Request.ReadFormAsync(); + var methodType = form[_options.FormFieldName!]; + if (!string.IsNullOrEmpty(methodType)) + { + context.Request.Method = methodType; + } await _next(context); } } diff --git a/src/Middleware/ResponseCompression/src/ResponseCompressionMiddleware.cs b/src/Middleware/ResponseCompression/src/ResponseCompressionMiddleware.cs index b645c902d614..ac63ca7d5e7d 100644 --- a/src/Middleware/ResponseCompression/src/ResponseCompressionMiddleware.cs +++ b/src/Middleware/ResponseCompression/src/ResponseCompressionMiddleware.cs @@ -44,14 +44,17 @@ public ResponseCompressionMiddleware(RequestDelegate next, IResponseCompressionP /// /// The . /// A task that represents the execution of this middleware. - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (!_provider.CheckRequestAcceptsCompression(context)) { - await _next(context); - return; + return _next(context); } + return InvokeCore(context); + } + private async Task InvokeCore(HttpContext context) + { var originalBodyFeature = context.Features.Get(); var originalCompressionFeature = context.Features.Get(); diff --git a/src/Middleware/Spa/SpaProxy/src/SpaProxyMiddleware.cs b/src/Middleware/Spa/SpaProxy/src/SpaProxyMiddleware.cs index 6233102bc533..1571ee306cb5 100644 --- a/src/Middleware/Spa/SpaProxy/src/SpaProxyMiddleware.cs +++ b/src/Middleware/Spa/SpaProxy/src/SpaProxyMiddleware.cs @@ -45,29 +45,31 @@ public SpaProxyMiddleware( _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (context.Request.Path.Equals(new Uri(_options.Value.ServerUrl).LocalPath)) { - context.Response.Headers[HeaderNames.CacheControl] = "no-cache, no-store, must-revalidate, max-age=0"; - if (!await _spaProxyLaunchManager.IsSpaProxyRunning(context.RequestAborted)) - { - _spaProxyLaunchManager.StartInBackground(_hostLifetime.ApplicationStopping); - _logger.LogInformation("SPA proxy is not ready. Returning temporary landing page."); - context.Response.ContentType = "text/html"; + return InvokeCore(context); + } + return _next(context); + } + + private async Task InvokeCore(HttpContext context) + { + context.Response.Headers[HeaderNames.CacheControl] = "no-cache, no-store, must-revalidate, max-age=0"; + if (!await _spaProxyLaunchManager.IsSpaProxyRunning(context.RequestAborted)) + { + _spaProxyLaunchManager.StartInBackground(_hostLifetime.ApplicationStopping); + _logger.LogInformation("SPA proxy is not ready. Returning temporary landing page."); + context.Response.ContentType = "text/html"; - await using var writer = new StreamWriter(context.Response.Body, Encoding.UTF8); - await writer.WriteAsync(GenerateSpaLaunchPage(_options.Value)); - } - else - { - _logger.LogInformation($"SPA proxy is ready. Redirecting to {_options.Value.ServerUrl}."); - context.Response.Redirect(_options.Value.ServerUrl); - } + await using var writer = new StreamWriter(context.Response.Body, Encoding.UTF8); + await writer.WriteAsync(GenerateSpaLaunchPage(_options.Value)); } else { - await _next(context); + _logger.LogInformation($"SPA proxy is ready. Redirecting to {_options.Value.ServerUrl}."); + context.Response.Redirect(_options.Value.ServerUrl); } string GenerateSpaLaunchPage(SpaDevelopmentServerOptions options) diff --git a/src/Middleware/Spa/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs b/src/Middleware/Spa/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs index b6e0f0f7e25c..9caf6c91b733 100644 --- a/src/Middleware/Spa/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs +++ b/src/Middleware/Spa/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs @@ -43,16 +43,22 @@ public ConditionalProxyMiddleware( _applicationStoppingToken = applicationLifetime.ApplicationStopping; } - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { if (context.Request.Path.StartsWithSegments(_pathPrefix) || _pathPrefixIsRoot) { - var didProxyRequest = await SpaProxy.PerformProxyRequest( - context, _httpClient, _baseUriTask, _applicationStoppingToken, proxy404s: false); - if (didProxyRequest) - { - return; - } + return InvokeCore(context); + } + return _next.Invoke(context); + } + + private async Task InvokeCore(HttpContext context) + { + var didProxyRequest = await SpaProxy.PerformProxyRequest( + context, _httpClient, _baseUriTask, _applicationStoppingToken, proxy404s: false); + if (didProxyRequest) + { + return; } // Not a request we can proxy diff --git a/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs b/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs index c030b81ec06d..6726215525c8 100644 --- a/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs +++ b/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs @@ -115,13 +115,13 @@ public IISMiddleware(RequestDelegate next, /// /// The . /// A that represents the asynchronous operation. - public async Task Invoke(HttpContext httpContext) + public Task Invoke(HttpContext httpContext) { if (!string.Equals(_pairingToken, httpContext.Request.Headers[MSAspNetCoreToken], StringComparison.Ordinal)) { _logger.LogError($"'{MSAspNetCoreToken}' does not match the expected pairing token '{_pairingToken}', request rejected."); httpContext.Response.StatusCode = StatusCodes.Status400BadRequest; - return; + return Task.CompletedTask; } // Handle shutdown from ANCM @@ -132,14 +132,14 @@ public async Task Invoke(HttpContext httpContext) // Execute shutdown task on background thread without waiting for completion var shutdownTask = Task.Run(() => _applicationLifetime.StopApplication()); httpContext.Response.StatusCode = StatusCodes.Status202Accepted; - return; + return Task.CompletedTask; } if (Debugger.IsAttached && string.Equals("DEBUG", httpContext.Request.Method, StringComparison.OrdinalIgnoreCase)) { // The Visual Studio debugger tooling sends a DEBUG request to make IIS & AspNetCoreModule launch the process // so the debugger can attach. Filter out this request from the app. - return; + return Task.CompletedTask; } var bodySizeFeature = httpContext.Features.Get(); @@ -181,7 +181,7 @@ public async Task Invoke(HttpContext httpContext) httpContext.Features.Set(null); } - await _next(httpContext); + return _next(httpContext); } private static WindowsPrincipal? GetUser(HttpContext context)