Skip to content

[main] Update dependencies from dotnet/runtime dotnet/efcore #42688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 138 additions & 138 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

138 changes: 69 additions & 69 deletions eng/Versions.props

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ValueTask<bool> TryEnterAsync()
return ValueTask.FromResult(true);
}

var task = _limiter.WaitAsync();
var task = _limiter.WaitAndAcquireAsync();
if (task.IsCompletedSuccessfully)
{
lease = task.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// The global limiter will be a concurrency limiter with a max permit count of 10 and a queue depth of 5.
options.GlobalLimiter = PartitionedRateLimiter.Create<HttpContext, string>(context =>
{
return RateLimitPartition.CreateConcurrencyLimiter<string>("globalLimiter", key => new ConcurrencyLimiterOptions(10, QueueProcessingOrder.NewestFirst, 5));
return RateLimitPartition.GetConcurrencyLimiter<string>("globalLimiter", key => new ConcurrencyLimiterOptions(10, QueueProcessingOrder.NewestFirst, 5));
});
app.UseRateLimiter(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public SampleRateLimiterPolicy(ILogger<SampleRateLimiterPolicy> logger)
// Use a sliding window limiter allowing 1 request every 10 seconds
public RateLimitPartition<string> GetPartition(HttpContext httpContext)
{
return RateLimitPartition.CreateSlidingWindowLimiter<string>(string.Empty, key => new SlidingWindowRateLimiterOptions(1, QueueProcessingOrder.OldestFirst, 1, TimeSpan.FromSeconds(5), 1));
return RateLimitPartition.GetSlidingWindowLimiter<string>(string.Empty, key => new SlidingWindowRateLimiterOptions(1, QueueProcessingOrder.OldestFirst, 1, TimeSpan.FromSeconds(5), 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static RateLimiterOptions AddTokenBucketLimiter(this RateLimiterOptions o
var key = new PolicyNameKey() { PolicyName = policyName };
return options.AddPolicy(policyName, context =>
{
return RateLimitPartition.CreateTokenBucketLimiter(key,
return RateLimitPartition.GetTokenBucketLimiter(key,
_ => tokenBucketRateLimiterOptions);
});
}
Expand All @@ -39,7 +39,7 @@ public static RateLimiterOptions AddFixedWindowLimiter(this RateLimiterOptions o
var key = new PolicyNameKey() { PolicyName = policyName };
return options.AddPolicy(policyName, context =>
{
return RateLimitPartition.CreateFixedWindowLimiter(key,
return RateLimitPartition.GetFixedWindowLimiter(key,
_ => fixedWindowRateLimiterOptions);
});
}
Expand All @@ -56,7 +56,7 @@ public static RateLimiterOptions AddSlidingWindowLimiter(this RateLimiterOptions
var key = new PolicyNameKey() { PolicyName = policyName };
return options.AddPolicy(policyName, context =>
{
return RateLimitPartition.CreateSlidingWindowLimiter(key,
return RateLimitPartition.GetSlidingWindowLimiter(key,
_ => slidingWindowRateLimiterOptions);
});
}
Expand All @@ -73,7 +73,7 @@ public static RateLimiterOptions AddConcurrencyLimiter(this RateLimiterOptions o
var key = new PolicyNameKey() { PolicyName = policyName };
return options.AddPolicy(policyName, context =>
{
return RateLimitPartition.CreateConcurrencyLimiter(key,
return RateLimitPartition.GetConcurrencyLimiter(key,
_ => concurrencyLimiterOptions);
});
}
Expand All @@ -89,7 +89,7 @@ public static RateLimiterOptions AddNoLimiter(this RateLimiterOptions options, s
var key = new PolicyNameKey() { PolicyName = policyName };
return options.AddPolicy(policyName, context =>
{
return RateLimitPartition.CreateNoLimiter(key);
return RateLimitPartition.GetNoLimiter(key);
});
}
}
6 changes: 3 additions & 3 deletions src/Middleware/RateLimiting/src/RateLimitingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ private async ValueTask<LeaseContext> CombinedWaitAsync(HttpContext context, Can
{
if (_globalLimiter is not null)
{
globalLease = await _globalLimiter.WaitAsync(context, cancellationToken: cancellationToken);
globalLease = await _globalLimiter.WaitAndAcquireAsync(context, cancellationToken: cancellationToken);
if (!globalLease.IsAcquired)
{
return new LeaseContext() { GlobalRejected = true, Lease = globalLease };
}
}
endpointLease = await _endpointLimiter.WaitAsync(context, cancellationToken: cancellationToken);
endpointLease = await _endpointLimiter.WaitAndAcquireAsync(context, cancellationToken: cancellationToken);
if (!endpointLease.IsAcquired)
{
globalLease?.Dispose();
Expand Down Expand Up @@ -183,7 +183,7 @@ private PartitionedRateLimiter<HttpContext> CreateEndpointLimiter()
throw new InvalidOperationException($"This endpoint requires a rate limiting policy with name {name}, but no such policy exists.");
}
}
return RateLimitPartition.CreateNoLimiter<DefaultKeyType>(_defaultPolicyKey);
return RateLimitPartition.GetNoLimiter<DefaultKeyType>(_defaultPolicyKey);
}, new DefaultKeyTypeEqualityComparer());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public async Task EndpointLimiter_Rejects()
var name = "myEndpoint";
options.Value.AddPolicy<string>(name, (context =>
{
return RateLimitPartition.Create<string>("myLimiter", (key =>
return RateLimitPartition.Get<string>("myLimiter", (key =>
{
return new TestRateLimiter(false);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RateLimitingOptionsTests
public void AddPolicy_ThrowsOnNullPolicyName()
{
var options = new RateLimiterOptions();
Assert.Throws<ArgumentNullException>(() => options.AddPolicy<string>(null, context => RateLimitPartition.CreateNoLimiter<string>("myKey")));
Assert.Throws<ArgumentNullException>(() => options.AddPolicy<string>(null, context => RateLimitPartition.GetNoLimiter<string>("myKey")));
}

[Fact]
Expand All @@ -34,15 +34,15 @@ public void AddPolicy_ThrowsOnNullPolicy()
public void AddPolicy_ThrowsOnDuplicateName()
{
var options = new RateLimiterOptions();
options.AddPolicy<string>("myKey", context => RateLimitPartition.CreateNoLimiter<string>("myKey"));
Assert.Throws<ArgumentException>(() => options.AddPolicy<string>("myKey", context => RateLimitPartition.CreateNoLimiter<string>("yourKey")));
options.AddPolicy<string>("myKey", context => RateLimitPartition.GetNoLimiter<string>("myKey"));
Assert.Throws<ArgumentException>(() => options.AddPolicy<string>("myKey", context => RateLimitPartition.GetNoLimiter<string>("yourKey")));
}

[Fact]
public void AddPolicy_Generic_ThrowsOnDuplicateName()
{
var options = new RateLimiterOptions();
options.AddPolicy<string>("myKey", context => RateLimitPartition.CreateNoLimiter<string>("myKey"));
options.AddPolicy<string>("myKey", context => RateLimitPartition.GetNoLimiter<string>("myKey"));
Assert.Throws<ArgumentException>(() => options.AddPolicy<string, TestRateLimiterPolicy>("myKey"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected override RateLimitLease AcquireCore(TResource resourceID, int permitCo
return new TestRateLimitLease(true, leases);
}

protected override async ValueTask<RateLimitLease> WaitAsyncCore(TResource resourceID, int permitCount, CancellationToken cancellationToken)
protected override async ValueTask<RateLimitLease> WaitAndAcquireAsyncCore(TResource resourceID, int permitCount, CancellationToken cancellationToken)
{
if (permitCount != 1)
{
Expand All @@ -66,7 +66,7 @@ protected override async ValueTask<RateLimitLease> WaitAsyncCore(TResource resou
var leases = new List<RateLimitLease>();
foreach (var limiter in limiters)
{
leases.Add(await limiter.WaitAsync());
leases.Add(await limiter.WaitAndAcquireAsync());
}
foreach (var lease in leases)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Middleware/RateLimiting/test/TestRateLimiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.RateLimiting;

namespace Microsoft.AspNetCore.RateLimiting;

internal class TestRateLimiter : RateLimiter
{
private readonly bool _alwaysAccept;
Expand All @@ -25,7 +26,7 @@ protected override RateLimitLease AcquireCore(int permitCount)
return new TestRateLimitLease(_alwaysAccept, null);
}

protected override ValueTask<RateLimitLease> WaitAsyncCore(int permitCount, CancellationToken cancellationToken)
protected override ValueTask<RateLimitLease> WaitAndAcquireAsyncCore(int permitCount, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return new ValueTask<RateLimitLease>(new TestRateLimitLease(_alwaysAccept, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public TestRateLimiterPolicy(string key, int statusCode, bool alwaysAccept)

public RateLimitPartition<string> GetPartition(HttpContext httpContext)
{
return RateLimitPartition.Create<string>(_key, (key =>
return RateLimitPartition.Get<string>(_key, (key =>
{
return new TestRateLimiter(_alwaysAccept);
}));
Expand Down
20 changes: 12 additions & 8 deletions src/Servers/HttpSys/test/FunctionalTests/Http3Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ public async Task Http3_ResetBeforeHeaders()
client.DefaultRequestVersion = HttpVersion.Version30;
client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact;
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address));
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException);
Assert.Equal(0x010b, qex.ErrorCode);
var qex = Assert.IsType<QuicException>(ex.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x010b, qex.ApplicationErrorCode.Value);
}

[ConditionalFact]
Expand Down Expand Up @@ -206,8 +207,9 @@ public async Task Http3_ResetAfterHeaders()
headersReceived.SetResult();
response.EnsureSuccessStatusCode();
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync());
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(0x010c, qex.ErrorCode);
var qex = Assert.IsType<QuicException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x010c, qex.ApplicationErrorCode.Value);
}

[ConditionalFact]
Expand All @@ -231,8 +233,9 @@ public async Task Http3_AppExceptionAfterHeaders_InternalError()
headersReceived.SetResult();
response.EnsureSuccessStatusCode();
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync());
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(0x0102, qex.ErrorCode); // H3_INTERNAL_ERROR
var qex = Assert.IsType<QuicException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x0102, qex.ApplicationErrorCode.Value); // H3_INTERNAL_ERROR
}

[ConditionalFact]
Expand All @@ -251,7 +254,8 @@ public async Task Http3_Abort_Cancel()
client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact;

var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address));
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException);
Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED
var qex = Assert.IsType<QuicException>(ex.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); // H3_REQUEST_CANCELLED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<TestGroupName>HttpSys.FunctionalTests</TestGroupName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Required for System.Net.Quic which has a preview API in .NET 7 -->
<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>

<ItemGroup>
Expand Down
20 changes: 12 additions & 8 deletions src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ public async Task Http3_ResetBeforeHeaders()
client.DefaultRequestVersion = HttpVersion.Version30;
client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact;
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address));
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException);
Assert.Equal(0x010b, qex.ErrorCode);
var qex = Assert.IsType<QuicException>(ex.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x010b, qex.ApplicationErrorCode.Value);
}

[ConditionalFact]
Expand All @@ -135,8 +136,9 @@ public async Task Http3_ResetAfterHeaders()
await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_ResetAfterHeaders_SetResult");
response.EnsureSuccessStatusCode();
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync());
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED
var qex = Assert.IsType<QuicException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); // H3_REQUEST_CANCELLED
}

[ConditionalFact]
Expand All @@ -151,8 +153,9 @@ public async Task Http3_AppExceptionAfterHeaders_InternalError()
await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_AppExceptionAfterHeaders_InternalError_SetResult");
response.EnsureSuccessStatusCode();
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync());
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(0x0102, qex.ErrorCode); // H3_INTERNAL_ERROR
var qex = Assert.IsType<QuicException>(ex.InnerException?.InnerException?.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x0102, qex.ApplicationErrorCode.Value); // H3_INTERNAL_ERROR
}

[ConditionalFact]
Expand All @@ -164,8 +167,9 @@ public async Task Http3_Abort_Cancel()
client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact;

var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address));
var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException);
Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED
var qex = Assert.IsType<QuicException>(ex.InnerException);
Assert.Equal(QuicError.StreamAborted, qex.QuicError);
Assert.Equal(0x010c, qex.ApplicationErrorCode.Value); // H3_REQUEST_CANCELLED
}

private HttpClient SetUpClient()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
Expand All @@ -7,6 +7,8 @@
<DisableFastUpToDateCheck>True</DisableFastUpToDateCheck>
<SkipTests Condition=" '$(SkipIISTests)' == 'true' ">true</SkipTests>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Required for System.Net.Quic which has a preview API in .NET 7 -->
<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>

<Import Project="../FunctionalTest.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ internal static SslServerAuthenticationOptions CloneSslOptions(SslServerAuthenti
ServerCertificate = sslOptions.ServerCertificate,
ServerCertificateContext = sslOptions.ServerCertificateContext,
ServerCertificateSelectionCallback = sslOptions.ServerCertificateSelectionCallback,
CertificateChainPolicy = sslOptions.CertificateChainPolicy,
};

private sealed class SniOptions
Expand Down
5 changes: 5 additions & 0 deletions src/Servers/Kestrel/Core/test/SniOptionsSelectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ public void CloneSslOptionsClonesAllProperties()
ServerCertificateContext = SslStreamCertificateContext.Create(_x509Certificate2, additionalCertificates: null, offline: true),
// Defaults to null
ServerCertificateSelectionCallback = (sender, serverName) => null,
// Defaults to null
CertificateChainPolicy = new X509ChainPolicy(),
};

var clonedOptions = SniOptionsSelector.CloneSslOptions(options);
Expand Down Expand Up @@ -836,6 +838,9 @@ public void CloneSslOptionsClonesAllProperties()
Assert.Same(options.ServerCertificateSelectionCallback, clonedOptions.ServerCertificateSelectionCallback);
Assert.True(propertyNames.Remove(nameof(options.ServerCertificateSelectionCallback)));

Assert.Same(options.CertificateChainPolicy, clonedOptions.CertificateChainPolicy);
Assert.True(propertyNames.Remove(nameof(options.CertificateChainPolicy)));

// Ensure we've checked every property. When new properties get added, we'll have to update this test along with the CloneSslOptions implementation.
Assert.Empty(propertyNames);
}
Expand Down
Loading