Skip to content

Commit

Permalink
Merge branch 'main' into mit-license
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilchie authored Jul 23, 2021
2 parents 252856f + 56d0f2a commit bc7d91f
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 136 deletions.
2 changes: 1 addition & 1 deletion docs/BuildFromSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Common properties include:

### Resx files

If you need to make changes to a .resx file, run `dotnet msbuild t:/Resgen <path to csproj>`. 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

Expand Down
32 changes: 16 additions & 16 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@
-->
<Dependencies>
<ProductDependencies>
<Dependency Name="dotnet-ef" Version="6.0.0-rc.1.21372.1">
<Dependency Name="dotnet-ef" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-rc.1.21372.1">
<Dependency Name="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-rc.1.21372.2">
<Uri>https://github.com/dotnet/efcore</Uri>
<Sha>4e3ce4e13036eaeac700b2a08faa0d45270beb6e</Sha>
<Sha>d37ad4507fb3e5d2aa25ec4ee69ab3134bd3e814</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0-rc.1.21372.1">
<Uri>https://github.com/dotnet/runtime</Uri>
Expand Down
16 changes: 8 additions & 8 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@
<!-- Only listed explicitly to workaround https://github.com/dotnet/cli/issues/10528 -->
<MicrosoftNETCorePlatformsVersion>6.0.0-rc.1.21372.1</MicrosoftNETCorePlatformsVersion>
<!-- Packages from dotnet/efcore -->
<dotnetefVersion>6.0.0-rc.1.21372.1</dotnetefVersion>
<MicrosoftEntityFrameworkCoreInMemoryVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreInMemoryVersion>
<MicrosoftEntityFrameworkCoreRelationalVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreRelationalVersion>
<MicrosoftEntityFrameworkCoreSqliteVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreSqliteVersion>
<MicrosoftEntityFrameworkCoreSqlServerVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreSqlServerVersion>
<MicrosoftEntityFrameworkCoreToolsVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreToolsVersion>
<MicrosoftEntityFrameworkCoreVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreVersion>
<MicrosoftEntityFrameworkCoreDesignVersion>6.0.0-rc.1.21372.1</MicrosoftEntityFrameworkCoreDesignVersion>
<dotnetefVersion>6.0.0-rc.1.21372.2</dotnetefVersion>
<MicrosoftEntityFrameworkCoreInMemoryVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreInMemoryVersion>
<MicrosoftEntityFrameworkCoreRelationalVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreRelationalVersion>
<MicrosoftEntityFrameworkCoreSqliteVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreSqliteVersion>
<MicrosoftEntityFrameworkCoreSqlServerVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreSqlServerVersion>
<MicrosoftEntityFrameworkCoreToolsVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreToolsVersion>
<MicrosoftEntityFrameworkCoreVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreVersion>
<MicrosoftEntityFrameworkCoreDesignVersion>6.0.0-rc.1.21372.2</MicrosoftEntityFrameworkCoreDesignVersion>
<!-- Packages from dotnet/arcade -->
<MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.21366.1</MicrosoftDotNetBuildTasksInstallersVersion>
<MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.21366.1</MicrosoftDotNetBuildTasksTemplatingVersion>
Expand Down
42 changes: 21 additions & 21 deletions src/Http/Http.Abstractions/src/Extensions/MapMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public MapMiddleware(RequestDelegate next, MapOptions options)
/// </summary>
/// <param name="context">The <see cref="HttpContext"/> for the current request.</param>
/// <returns>A task that represents the execution of this middleware.</returns>
public async Task Invoke(HttpContext context)
public Task Invoke(HttpContext context)
{
if (context == null)
{
Expand All @@ -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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MapWhenMiddleware(RequestDelegate next, MapWhenOptions options)
/// </summary>
/// <param name="context">The <see cref="HttpContext"/> for the current request.</param>
/// <returns>A task that represents the execution of this middleware.</returns>
public async Task Invoke(HttpContext context)
public Task Invoke(HttpContext context)
{
if (context == null)
{
Expand All @@ -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);
}
}
}
43 changes: 21 additions & 22 deletions src/Http/Http.Abstractions/src/Extensions/UsePathBaseMiddleware.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,37 +41,36 @@ public UsePathBaseMiddleware(RequestDelegate next, PathString pathBase)
/// </summary>
/// <param name="context">The <see cref="HttpContext"/> for the current request.</param>
/// <returns>A task that represents the execution of this middleware.</returns>
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;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public MigrationsEndPointMiddleware(
/// </summary>
/// <param name="context">The context for the current request.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
public virtual async Task Invoke(HttpContext context)
public virtual Task Invoke(HttpContext context)
{
if (context == null)
{
Expand All @@ -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<DbContext?> GetDbContext(HttpContext context, ILogger logger)
Expand Down
20 changes: 13 additions & 7 deletions src/Middleware/HttpOverrides/src/HttpMethodOverrideMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,15 @@ public HttpMethodOverrideMiddleware(RequestDelegate next, IOptions<HttpMethodOve
/// Executes the middleware.
/// </summary>
/// <param name="context">The <see cref="HttpContext"/> for the current request.</param>
public async Task Invoke(HttpContext context)
public Task Invoke(HttpContext context)
{
if (HttpMethods.IsPost(context.Request.Method))
{
if (_options.FormFieldName != null)
{
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
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ public ResponseCompressionMiddleware(RequestDelegate next, IResponseCompressionP
/// </summary>
/// <param name="context">The <see cref="HttpContext"/>.</param>
/// <returns>A task that represents the execution of this middleware.</returns>
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<IHttpResponseBodyFeature>();
var originalCompressionFeature = context.Features.Get<IHttpsCompressionFeature>();

Expand Down
Loading

0 comments on commit bc7d91f

Please sign in to comment.