Skip to content

Commit 19a2bd0

Browse files
[release/7.0-preview6] Update dependencies from dotnet/runtime dotnet/efcore (#42358)
* Update dependencies from https://github.com/dotnet/efcore build 20220622.4 dotnet-ef , Microsoft.EntityFrameworkCore , Microsoft.EntityFrameworkCore.Design , Microsoft.EntityFrameworkCore.InMemory , Microsoft.EntityFrameworkCore.Relational , Microsoft.EntityFrameworkCore.Sqlite , Microsoft.EntityFrameworkCore.SqlServer , Microsoft.EntityFrameworkCore.Tools From Version 7.0.0-preview.6.22322.3 -> To Version 7.0.0-preview.6.22322.4 * Update dependencies from https://github.com/dotnet/runtime build 20220623.3 Microsoft.Extensions.Caching.Abstractions , Microsoft.Extensions.Caching.Memory , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Binder , Microsoft.Extensions.Configuration.CommandLine , Microsoft.Extensions.Configuration.EnvironmentVariables , Microsoft.Extensions.Configuration.FileExtensions , Microsoft.Extensions.Configuration.Ini , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.Configuration.UserSecrets , Microsoft.Extensions.Configuration.Xml , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.DependencyModel , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.FileProviders.Composite , Microsoft.Extensions.FileProviders.Physical , Microsoft.Extensions.FileSystemGlobbing , Microsoft.Extensions.HostFactoryResolver.Sources , Microsoft.Extensions.Hosting , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Http , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Configuration , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Logging.EventLog , Microsoft.Extensions.Logging.EventSource , Microsoft.Extensions.Logging.TraceSource , Microsoft.Extensions.Options , Microsoft.Extensions.Options.ConfigurationExtensions , Microsoft.Extensions.Options.DataAnnotations , Microsoft.Extensions.Primitives , Microsoft.Internal.Runtime.AspNetCore.Transport , Microsoft.NET.Runtime.MonoAOTCompiler.Task , Microsoft.NET.Runtime.WebAssembly.Sdk , Microsoft.NETCore.App.Ref , Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.BrowserDebugHost.Transport , Microsoft.NETCore.Platforms , System.Configuration.ConfigurationManager , System.Diagnostics.DiagnosticSource , System.Diagnostics.EventLog , System.DirectoryServices.Protocols , System.IO.Pipelines , System.Net.Http.Json , System.Net.Http.WinHttpHandler , System.Reflection.Metadata , System.Resources.Extensions , System.Security.Cryptography.Pkcs , System.Security.Cryptography.Xml , System.Security.Permissions , System.ServiceProcess.ServiceController , System.Text.Encodings.Web , System.Text.Json , System.Threading.AccessControl , System.Threading.Channels , System.Threading.RateLimiting From Version 7.0.0-preview.6.22321.8 -> To Version 7.0.0-preview.6.22323.3 * Update dependencies from https://github.com/dotnet/runtime build 20220623.6 Microsoft.Extensions.Caching.Abstractions , Microsoft.Extensions.Caching.Memory , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Binder , Microsoft.Extensions.Configuration.CommandLine , Microsoft.Extensions.Configuration.EnvironmentVariables , Microsoft.Extensions.Configuration.FileExtensions , Microsoft.Extensions.Configuration.Ini , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.Configuration.UserSecrets , Microsoft.Extensions.Configuration.Xml , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.DependencyModel , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.FileProviders.Composite , Microsoft.Extensions.FileProviders.Physical , Microsoft.Extensions.FileSystemGlobbing , Microsoft.Extensions.HostFactoryResolver.Sources , Microsoft.Extensions.Hosting , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Http , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Configuration , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Logging.EventLog , Microsoft.Extensions.Logging.EventSource , Microsoft.Extensions.Logging.TraceSource , Microsoft.Extensions.Options , Microsoft.Extensions.Options.ConfigurationExtensions , Microsoft.Extensions.Options.DataAnnotations , Microsoft.Extensions.Primitives , Microsoft.Internal.Runtime.AspNetCore.Transport , Microsoft.NET.Runtime.MonoAOTCompiler.Task , Microsoft.NET.Runtime.WebAssembly.Sdk , Microsoft.NETCore.App.Ref , Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.BrowserDebugHost.Transport , Microsoft.NETCore.Platforms , System.Configuration.ConfigurationManager , System.Diagnostics.DiagnosticSource , System.Diagnostics.EventLog , System.DirectoryServices.Protocols , System.IO.Pipelines , System.Net.Http.Json , System.Net.Http.WinHttpHandler , System.Reflection.Metadata , System.Resources.Extensions , System.Security.Cryptography.Pkcs , System.Security.Cryptography.Xml , System.Security.Permissions , System.ServiceProcess.ServiceController , System.Text.Encodings.Web , System.Text.Json , System.Threading.AccessControl , System.Threading.Channels , System.Threading.RateLimiting From Version 7.0.0-preview.6.22321.8 -> To Version 7.0.0-preview.6.22323.6 * Update dependencies from https://github.com/dotnet/efcore build 20220623.4 dotnet-ef , Microsoft.EntityFrameworkCore , Microsoft.EntityFrameworkCore.Design , Microsoft.EntityFrameworkCore.InMemory , Microsoft.EntityFrameworkCore.Relational , Microsoft.EntityFrameworkCore.Sqlite , Microsoft.EntityFrameworkCore.SqlServer , Microsoft.EntityFrameworkCore.Tools From Version 7.0.0-preview.6.22322.3 -> To Version 7.0.0-preview.6.22323.4 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
1 parent 32dfb41 commit 19a2bd0

27 files changed

+1318
-340
lines changed

eng/Version.Details.xml

Lines changed: 138 additions & 138 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 75 additions & 69 deletions
Large diffs are not rendered by default.

src/Middleware/OutputCaching/test/MemoryOutputCacheStoreTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class MemoryOutputCacheStoreTests
1616
public async Task StoreAndGetValue_Succeeds()
1717
{
1818
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions()));
19-
var value = "abc"u8;
19+
var value = "abc"u8.ToArray();
2020
var key = "abc";
2121

2222
await store.SetAsync(key, value, null, TimeSpan.FromMinutes(1), default);
@@ -31,7 +31,7 @@ public async Task StoreAndGetValue_TimesOut()
3131
{
3232
var testClock = new TestMemoryOptionsClock { UtcNow = DateTimeOffset.UtcNow };
3333
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions { Clock = testClock }));
34-
var value = "abc"u8;
34+
var value = "abc"u8.ToArray();
3535
var key = "abc";
3636

3737
await store.SetAsync(key, value, null, TimeSpan.FromMilliseconds(5), default);
@@ -46,7 +46,7 @@ public async Task StoreAndGetValue_TimesOut()
4646
public async Task StoreNullKey_ThrowsException()
4747
{
4848
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions()));
49-
var value = "abc"u8;
49+
var value = "abc"u8.ToArray();
5050
string key = null;
5151

5252
_ = await Assert.ThrowsAsync<ArgumentNullException>("key", () => store.SetAsync(key, value, null, TimeSpan.FromMilliseconds(5), default).AsTask());
@@ -67,7 +67,7 @@ public async Task EvictByTag_SingleTag_SingleEntry()
6767
{
6868
var testClock = new TestMemoryOptionsClock { UtcNow = DateTimeOffset.UtcNow };
6969
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions { Clock = testClock }));
70-
var value = "abc"u8;
70+
var value = "abc"u8.ToArray();
7171
var key = "abc";
7272
var tags = new string[] { "tag1" };
7373

@@ -83,7 +83,7 @@ public async Task EvictByTag_SingleTag_MultipleEntries()
8383
{
8484
var testClock = new TestMemoryOptionsClock { UtcNow = DateTimeOffset.UtcNow };
8585
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions { Clock = testClock }));
86-
var value = "abc"u8;
86+
var value = "abc"u8.ToArray();
8787
var key1 = "abc";
8888
var key2 = "def";
8989
var tags = new string[] { "tag1" };
@@ -103,7 +103,7 @@ public async Task EvictByTag_MultipleTags_SingleEntry()
103103
{
104104
var testClock = new TestMemoryOptionsClock { UtcNow = DateTimeOffset.UtcNow };
105105
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions { Clock = testClock }));
106-
var value = "abc"u8;
106+
var value = "abc"u8.ToArray();
107107
var key = "abc";
108108
var tags = new string[] { "tag1", "tag2" };
109109

@@ -119,7 +119,7 @@ public async Task EvictByTag_MultipleTags_MultipleEntries()
119119
{
120120
var testClock = new TestMemoryOptionsClock { UtcNow = DateTimeOffset.UtcNow };
121121
var store = new MemoryOutputCacheStore(new MemoryCache(new MemoryCacheOptions { Clock = testClock }));
122-
var value = "abc"u8;
122+
var value = "abc"u8.ToArray();
123123
var key1 = "abc";
124124
var key2 = "def";
125125
var tags1 = new string[] { "tag1", "tag2" };

src/Middleware/OutputCaching/test/OutputCacheEntryFormatterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task StoreAndGet_StoresAllValues()
3838
var key = "abc";
3939
var entry = new OutputCacheEntry()
4040
{
41-
Body = new CachedResponseBody(new List<byte[]>() { "lorem"u8, "ipsum"u8 }, 10),
41+
Body = new CachedResponseBody(new List<byte[]>() { "lorem"u8.ToArray(), "ipsum"u8.ToArray() }, 10),
4242
Created = DateTimeOffset.UtcNow,
4343
Headers = new HeaderDictionary { [HeaderNames.Accept] = "text/plain", [HeaderNames.AcceptCharset] = "utf8" },
4444
StatusCode = StatusCodes.Status201Created,
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Threading.RateLimiting;
5+
6+
namespace Microsoft.AspNetCore.RateLimiting;
7+
8+
internal sealed class DefaultCombinedLease : RateLimitLease
9+
{
10+
private readonly RateLimitLease? _globalLease;
11+
private readonly RateLimitLease _endpointLease;
12+
private HashSet<string>? _metadataNames;
13+
14+
public DefaultCombinedLease(RateLimitLease? globalLease, RateLimitLease endpointLease)
15+
{
16+
_globalLease = globalLease;
17+
_endpointLease = endpointLease;
18+
}
19+
20+
public override bool IsAcquired => true;
21+
22+
public override IEnumerable<string> MetadataNames
23+
{
24+
get
25+
{
26+
if (_metadataNames is null)
27+
{
28+
_metadataNames = new HashSet<string>();
29+
if (_globalLease is not null)
30+
{
31+
foreach (string metadataName in _globalLease.MetadataNames)
32+
{
33+
_metadataNames.Add(metadataName);
34+
}
35+
}
36+
foreach (string metadataName in _endpointLease.MetadataNames)
37+
{
38+
_metadataNames.Add(metadataName);
39+
}
40+
}
41+
return _metadataNames;
42+
}
43+
}
44+
45+
public override bool TryGetMetadata(string metadataName, out object? metadata)
46+
{
47+
// Use the first metadata item of a given name, ignore duplicates, we can't reliably merge arbitrary metadata
48+
// Creating an object[] if there are multiple of the same metadataName could work, but makes consumption of metadata messy
49+
// and makes MetadataName.Create<T>(...) uses no longer work
50+
if (_endpointLease.TryGetMetadata(metadataName, out metadata))
51+
{
52+
return true;
53+
}
54+
if (_globalLease is not null)
55+
{
56+
if (_globalLease.TryGetMetadata(metadataName, out metadata))
57+
{
58+
return true;
59+
}
60+
}
61+
62+
metadata = null;
63+
return false;
64+
}
65+
66+
protected override void Dispose(bool disposing)
67+
{
68+
List<Exception>? exceptions = null;
69+
70+
// Dispose endpoint lease first, then global lease (reverse order of when they were acquired)
71+
// Avoids issues where dispose might unblock a queued acquire and then the acquire fails when acquiring the next limiter.
72+
// When disposing in reverse order there wont be any issues of unblocking an acquire that affects acquires on limiters in the chain after it
73+
try
74+
{
75+
_endpointLease.Dispose();
76+
}
77+
catch (Exception ex)
78+
{
79+
exceptions ??= new List<Exception>();
80+
exceptions.Add(ex);
81+
}
82+
83+
try
84+
{
85+
_globalLease?.Dispose();
86+
}
87+
catch (Exception ex)
88+
{
89+
exceptions ??= new List<Exception>();
90+
exceptions.Add(ex);
91+
}
92+
93+
if (exceptions is not null)
94+
{
95+
throw new AggregateException(exceptions);
96+
}
97+
}
98+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.RateLimiting;
5+
6+
internal sealed class DefaultKeyType<TKey>: DefaultKeyType
7+
{
8+
private readonly TKey _key;
9+
10+
public DefaultKeyType(TKey key)
11+
{
12+
_key = key;
13+
}
14+
15+
public override object? GetKey()
16+
{
17+
return _key;
18+
}
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.RateLimiting;
5+
6+
internal abstract class DefaultKeyType
7+
{
8+
public abstract object? GetKey();
9+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics.CodeAnalysis;
5+
6+
namespace Microsoft.AspNetCore.RateLimiting;
7+
internal class DefaultKeyTypeEqualityComparer : IEqualityComparer<DefaultKeyType>
8+
{
9+
public bool Equals(DefaultKeyType? x, DefaultKeyType? y)
10+
{
11+
if (x == null && y == null)
12+
{
13+
return true;
14+
}
15+
else if (x == null || y == null)
16+
{
17+
return false;
18+
}
19+
20+
var xKey = x.GetKey();
21+
var yKey = y.GetKey();
22+
if (xKey == null && yKey == null)
23+
{
24+
return true;
25+
}
26+
else if (xKey == null || yKey == null)
27+
{
28+
return false;
29+
}
30+
31+
return xKey.Equals(yKey);
32+
}
33+
34+
public int GetHashCode([DisallowNull] DefaultKeyType obj)
35+
{
36+
var key = obj.GetKey();
37+
if (key is not null)
38+
{
39+
return key.GetHashCode();
40+
}
41+
// REVIEW - is this reasonable?
42+
return default;
43+
}
44+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Threading.RateLimiting;
5+
using Microsoft.AspNetCore.Http;
6+
7+
namespace Microsoft.AspNetCore.RateLimiting;
8+
internal sealed class DefaultRateLimiterPolicy : IRateLimiterPolicy<DefaultKeyType>
9+
{
10+
private readonly Func<HttpContext, RateLimitPartition<DefaultKeyType>> _partitioner;
11+
private readonly Func<OnRejectedContext, CancellationToken, ValueTask>? _onRejected;
12+
13+
public DefaultRateLimiterPolicy(Func<HttpContext, RateLimitPartition<DefaultKeyType>> partitioner, Func<OnRejectedContext, CancellationToken, ValueTask>? onRejected)
14+
{
15+
_partitioner = partitioner;
16+
_onRejected = onRejected;
17+
}
18+
19+
public Func<OnRejectedContext, CancellationToken, ValueTask>? OnRejected => _onRejected;
20+
21+
public RateLimitPartition<DefaultKeyType> GetPartition(HttpContext httpContext)
22+
{
23+
return _partitioner(httpContext);
24+
}
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.RateLimiting;
5+
6+
/// <summary>
7+
/// An interface which can be used to identify a type which provides metadata needed for enabling request rate limiting support.
8+
/// </summary>
9+
internal interface IRateLimiterMetadata
10+
{
11+
/// <summary>
12+
/// The name of the limiter which needs to be applied.
13+
/// </summary>
14+
string PolicyName { get; }
15+
}

0 commit comments

Comments
 (0)