Skip to content

Commit 645af5e

Browse files
authored
Merge branch 'main' into jamesnk/linkertest
2 parents 8eb4114 + 8ca5d1e commit 645af5e

File tree

61 files changed

+1114
-2668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1114
-2668
lines changed

.github/CODEOWNERS

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# See https://help.github.com/articles/about-code-owners/
33

44
* @Pilchie
5-
/global.json @dotnet/aspnet-build
6-
/.azure/ @dotnet/aspnet-build
7-
/.azuredevops/ @dotnet/aspnet-build
8-
/.config/ @dotnet/aspnet-build
5+
/global.json @dotnet/aspnet-build @dougbu @wtgodbe
6+
/.azure/ @dotnet/aspnet-build @dougbu @wtgodbe
7+
/.azuredevops/ @dotnet/aspnet-build @dougbu @wtgodbe
8+
/.config/ @dotnet/aspnet-build @dougbu @wtgodbe
99
/.devcontainer/ @captainsafia @TanayParikh
1010
/.vscode/ @captainsafia @TanayParikh
11-
/.github/ @dotnet/aspnet-build
12-
/.github/*_TEMPLATE/ @dotnet/aspnet-build @mkArtakMSFT
13-
/.github/workflows/ @dotnet/aspnet-build @tratcher
11+
/.github/ @dotnet/aspnet-build @dougbu @wtgodbe
12+
/.github/*_TEMPLATE/ @dotnet/aspnet-build @dougbu @wtgodbe @mkArtakMSFT
13+
/.github/workflows/ @dotnet/aspnet-build @dougbu @wtgodbe @tratcher
1414
/docs/ @captainsafia @mkArtakMSFT
15-
/eng/ @dotnet/aspnet-build
15+
/eng/ @dotnet/aspnet-build @dougbu @wtgodbe
1616
/eng/common/ @dotnet-maestro-bot
17-
/eng/Versions.props @dotnet-maestro-bot @dougbu
18-
/eng/Version.Details.xml @dotnet-maestro-bot @dougbu
17+
/eng/Versions.props @dotnet-maestro-bot @dotnet/aspnet-build @dougbu @wtgodbe
18+
/eng/Version.Details.xml @dotnet-maestro-bot @dotnet/aspnet-build @dougbu @wtgodbe
1919
/src/Caching/ @captainsafia @halter73
2020
/src/Caching/**/PublicAPI.*Shipped.txt @dotnet/aspnet-api-review @captainsafia @halter73
2121
/src/Components/ @dotnet/aspnet-blazor-eng

eng/Version.Details.xml

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

eng/Versions.props

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

src/Antiforgery/src/Internal/AntiforgeryLoggerExtensions.cs

Lines changed: 22 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,103 +5,35 @@
55

66
namespace Microsoft.AspNetCore.Antiforgery;
77

8-
internal static class AntiforgeryLoggerExtensions
8+
internal static partial class AntiforgeryLoggerExtensions
99
{
10-
private static readonly Action<ILogger, Exception?> _failedToDeserialzeTokens;
11-
private static readonly Action<ILogger, string, Exception?> _validationFailed;
12-
private static readonly Action<ILogger, Exception?> _validated;
13-
private static readonly Action<ILogger, string?, Exception?> _missingCookieToken;
14-
private static readonly Action<ILogger, string, string?, Exception?> _missingRequestToken;
15-
private static readonly Action<ILogger, Exception?> _newCookieToken;
16-
private static readonly Action<ILogger, Exception?> _reusedCookieToken;
17-
private static readonly Action<ILogger, Exception?> _tokenDeserializeException;
18-
private static readonly Action<ILogger, Exception?> _responseCacheHeadersOverridenToNoCache;
10+
[LoggerMessage(1, LogLevel.Warning, "Antiforgery validation failed with message '{Message}'.", EventName = "ValidationFailed")]
11+
public static partial void ValidationFailed(this ILogger logger, string message);
1912

20-
static AntiforgeryLoggerExtensions()
21-
{
22-
_validationFailed = LoggerMessage.Define<string>(
23-
LogLevel.Warning,
24-
new EventId(1, "ValidationFailed"),
25-
"Antiforgery validation failed with message '{Message}'.");
26-
_validated = LoggerMessage.Define(
27-
LogLevel.Debug,
28-
new EventId(2, "Validated"),
29-
"Antiforgery successfully validated a request.");
30-
_missingCookieToken = LoggerMessage.Define<string?>(
31-
LogLevel.Warning,
32-
new EventId(3, "MissingCookieToken"),
33-
"The required antiforgery cookie '{CookieName}' is not present.");
34-
_missingRequestToken = LoggerMessage.Define<string, string?>(
35-
LogLevel.Warning,
36-
new EventId(4, "MissingRequestToken"),
37-
"The required antiforgery request token was not provided in either form field '{FormFieldName}' "
38-
+ "or header '{HeaderName}'.");
39-
_newCookieToken = LoggerMessage.Define(
40-
LogLevel.Debug,
41-
new EventId(5, "NewCookieToken"),
42-
"A new antiforgery cookie token was created.");
43-
_reusedCookieToken = LoggerMessage.Define(
44-
LogLevel.Debug,
45-
new EventId(6, "ReusedCookieToken"),
46-
"An antiforgery cookie token was reused.");
47-
_tokenDeserializeException = LoggerMessage.Define(
48-
LogLevel.Error,
49-
new EventId(7, "TokenDeserializeException"),
50-
"An exception was thrown while deserializing the token.");
51-
_responseCacheHeadersOverridenToNoCache = LoggerMessage.Define(
52-
LogLevel.Warning,
53-
new EventId(8, "ResponseCacheHeadersOverridenToNoCache"),
54-
"The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and " +
55-
"'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery " +
56-
"should not be cached.");
57-
_failedToDeserialzeTokens = LoggerMessage.Define(
58-
LogLevel.Debug,
59-
new EventId(9, "FailedToDeserialzeTokens"),
60-
"Failed to deserialize antiforgery tokens.");
61-
}
62-
63-
public static void ValidationFailed(this ILogger logger, string message)
64-
{
65-
_validationFailed(logger, message, null);
66-
}
13+
[LoggerMessage(2, LogLevel.Debug, "Antiforgery successfully validated a request.", EventName = "Validated")]
14+
public static partial void ValidatedAntiforgeryToken(this ILogger logger);
6715

68-
public static void ValidatedAntiforgeryToken(this ILogger logger)
69-
{
70-
_validated(logger, null);
71-
}
16+
[LoggerMessage(3, LogLevel.Warning, "The required antiforgery cookie '{CookieName}' is not present.", EventName = "MissingCookieToken")]
17+
public static partial void MissingCookieToken(this ILogger logger, string? cookieName);
7218

73-
public static void MissingCookieToken(this ILogger logger, string? cookieName)
74-
{
75-
_missingCookieToken(logger, cookieName, null);
76-
}
19+
[LoggerMessage(4, LogLevel.Warning, "The required antiforgery request token was not provided in either form field '{FormFieldName}' "
20+
+ "or header '{HeaderName}'.", EventName = "MissingRequestToken")]
21+
public static partial void MissingRequestToken(this ILogger logger, string formFieldName, string? headerName);
7722

78-
public static void MissingRequestToken(this ILogger logger, string formFieldName, string? headerName)
79-
{
80-
_missingRequestToken(logger, formFieldName, headerName, null);
81-
}
23+
[LoggerMessage(5, LogLevel.Debug, "A new antiforgery cookie token was created.", EventName = "NewCookieToken")]
24+
public static partial void NewCookieToken(this ILogger logger);
8225

83-
public static void NewCookieToken(this ILogger logger)
84-
{
85-
_newCookieToken(logger, null);
86-
}
26+
[LoggerMessage(6, LogLevel.Debug, "An antiforgery cookie token was reused.", EventName = "ReusedCookieToken")]
27+
public static partial void ReusedCookieToken(this ILogger logger);
8728

88-
public static void ReusedCookieToken(this ILogger logger)
89-
{
90-
_reusedCookieToken(logger, null);
91-
}
29+
[LoggerMessage(7, LogLevel.Error, "An exception was thrown while deserializing the token.", EventName = "TokenDeserializeException")]
30+
public static partial void TokenDeserializeException(this ILogger logger, Exception exception);
9231

93-
public static void TokenDeserializeException(this ILogger logger, Exception exception)
94-
{
95-
_tokenDeserializeException(logger, exception);
96-
}
97-
98-
public static void ResponseCacheHeadersOverridenToNoCache(this ILogger logger)
99-
{
100-
_responseCacheHeadersOverridenToNoCache(logger, null);
101-
}
32+
[LoggerMessage(8, LogLevel.Warning, "The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and " +
33+
"'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery " +
34+
"should not be cached.", EventName = "ResponseCacheHeadersOverridenToNoCache")]
35+
public static partial void ResponseCacheHeadersOverridenToNoCache(this ILogger logger);
10236

103-
public static void FailedToDeserialzeTokens(this ILogger logger, Exception exception)
104-
{
105-
_failedToDeserialzeTokens(logger, exception);
106-
}
37+
[LoggerMessage(9, LogLevel.Debug, "Failed to deserialize antiforgery tokens.", EventName = "FailedToDeserialzeTokens")]
38+
public static partial void FailedToDeserialzeTokens(this ILogger logger, Exception exception);
10739
}

src/Caching/SqlServer/src/DatabaseOperations.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ public void DeleteCacheItem(string key)
7777
}
7878
}
7979

80-
public virtual byte[] GetCacheItem(string key)
80+
public virtual byte[]? GetCacheItem(string key)
8181
{
8282
return GetCacheItem(key, includeValue: true);
8383
}
8484

85-
public virtual async Task<byte[]> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken))
85+
public virtual async Task<byte[]?> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken))
8686
{
8787
token.ThrowIfCancellationRequested();
8888

@@ -194,7 +194,7 @@ public virtual void SetCacheItem(string key, byte[] value, DistributedCacheEntry
194194
}
195195
}
196196

197-
protected virtual byte[] GetCacheItem(string key, bool includeValue)
197+
protected virtual byte[]? GetCacheItem(string key, bool includeValue)
198198
{
199199
var utcNow = SystemClock.UtcNow;
200200

@@ -208,7 +208,7 @@ protected virtual byte[] GetCacheItem(string key, bool includeValue)
208208
query = SqlQueries.GetCacheItemWithoutValue;
209209
}
210210

211-
byte[] value = null;
211+
byte[]? value = null;
212212
using (var connection = new SqlConnection(ConnectionString))
213213
using (var command = new SqlCommand(query, connection))
214214
{
@@ -238,7 +238,7 @@ protected virtual byte[] GetCacheItem(string key, bool includeValue)
238238
return value;
239239
}
240240

241-
protected virtual async Task<byte[]> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
241+
protected virtual async Task<byte[]?> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
242242
{
243243
token.ThrowIfCancellationRequested();
244244

@@ -254,7 +254,7 @@ protected virtual byte[] GetCacheItem(string key, bool includeValue)
254254
query = SqlQueries.GetCacheItemWithoutValue;
255255
}
256256

257-
byte[] value = null;
257+
byte[]? value = null;
258258
using (var connection = new SqlConnection(ConnectionString))
259259
using (var command = new SqlCommand(query, connection))
260260
{

src/Caching/SqlServer/src/IDatabaseOperations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace Microsoft.Extensions.Caching.SqlServer;
99

1010
internal interface IDatabaseOperations
1111
{
12-
byte[] GetCacheItem(string key);
12+
byte[]? GetCacheItem(string key);
1313

14-
Task<byte[]> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken));
14+
Task<byte[]?> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken));
1515

1616
void RefreshCacheItem(string key);
1717

src/Caching/SqlServer/src/Microsoft.Extensions.Caching.SqlServer.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using Microsoft SQL Server.</Description>
@@ -9,7 +9,6 @@
99
<NoWarn>$(NoWarn);PKG0001</NoWarn>
1010
<IsPackable>true</IsPackable>
1111
<IsShipping>true</IsShipping>
12-
<Nullable>disable</Nullable>
1312
</PropertyGroup>
1413

1514
<ItemGroup>

src/Caching/SqlServer/src/MonoDatabaseOperations.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public MonoDatabaseOperations(
1818
{
1919
}
2020

21-
protected override byte[] GetCacheItem(string key, bool includeValue)
21+
protected override byte[]? GetCacheItem(string key, bool includeValue)
2222
{
2323
var utcNow = SystemClock.UtcNow;
2424

@@ -32,7 +32,7 @@ protected override byte[] GetCacheItem(string key, bool includeValue)
3232
query = SqlQueries.GetCacheItemWithoutValue;
3333
}
3434

35-
byte[] value = null;
35+
byte[]? value = null;
3636
using (var connection = new SqlConnection(ConnectionString))
3737
{
3838
var command = new SqlCommand(query, connection);
@@ -60,7 +60,7 @@ protected override byte[] GetCacheItem(string key, bool includeValue)
6060
return value;
6161
}
6262

63-
protected override async Task<byte[]> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
63+
protected override async Task<byte[]?> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
6464
{
6565
token.ThrowIfCancellationRequested();
6666

@@ -76,7 +76,7 @@ protected override byte[] GetCacheItem(string key, bool includeValue)
7676
query = SqlQueries.GetCacheItemWithoutValue;
7777
}
7878

79-
byte[] value = null;
79+
byte[]? value = null;
8080
using (var connection = new SqlConnection(ConnectionString))
8181
{
8282
var command = new SqlCommand(query, connection);

src/Caching/SqlServer/src/PublicAPI.Shipped.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#nullable enable
2-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Get(string key) -> byte[]
3-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.GetAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<byte[]>
4-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Refresh(string key) -> void
5-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RefreshAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
6-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Remove(string key) -> void
7-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RemoveAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
8-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Set(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options) -> void
9-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SetAsync(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
10-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SqlServerCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions> options) -> void
11-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.get -> string
12-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.set -> void
13-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.get -> string
14-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.set -> void
15-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.get -> Microsoft.Extensions.Internal.ISystemClock
16-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void
17-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string
18-
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void
19-
~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions> setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
2+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Get(string! key) -> byte[]?
3+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.GetAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<byte[]?>!
4+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Refresh(string! key) -> void
5+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RefreshAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
6+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Remove(string! key) -> void
7+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RemoveAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
8+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Set(string! key, byte[]! value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options) -> void
9+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SetAsync(string! key, byte[]! value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
10+
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SqlServerCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions!>! options) -> void
11+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.get -> string?
12+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.set -> void
13+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.get -> string?
14+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.set -> void
15+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.get -> Microsoft.Extensions.Internal.ISystemClock!
16+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void
17+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string?
18+
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void
19+
static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions!>! setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
2020
Microsoft.Extensions.Caching.SqlServer.SqlServerCache
2121
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions
2222
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.DefaultSlidingExpiration.get -> System.TimeSpan

0 commit comments

Comments
 (0)