Skip to content

Commit d23df36

Browse files
committed
Merge remote-tracking branch 'origin/main' into mbuck/passkey-api-follow-ups
2 parents 6e62bc2 + 57641e8 commit d23df36

File tree

14 files changed

+546
-332
lines changed

14 files changed

+546
-332
lines changed

AspNetCore.slnx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,20 +1143,10 @@
11431143
<Project Path="src/SignalR/server/StackExchangeRedis/src/Microsoft.AspNetCore.SignalR.StackExchangeRedis.csproj" />
11441144
<Project Path="src/SignalR/server/StackExchangeRedis/test/Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests.csproj" />
11451145
</Folder>
1146-
<Folder Name="/src/SiteExtensions/">
1147-
<Project Path="src/SiteExtensions/LoggingBranch/LB.csproj" />
1148-
</Folder>
1149-
<Folder Name="/src/SiteExtensions/LoggingAggregate/">
1150-
<Project Path="src/SiteExtensions/LoggingAggregate/src/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj" />
1151-
<Project Path="src/SiteExtensions/LoggingAggregate/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests.csproj" />
1152-
</Folder>
11531146
<Folder Name="/src/SiteExtensions/Microsoft.Web.Xdt.Extensions/">
11541147
<Project Path="src/SiteExtensions/Microsoft.Web.Xdt.Extensions/src/Microsoft.Web.Xdt.Extensions.csproj" />
11551148
<Project Path="src/SiteExtensions/Microsoft.Web.Xdt.Extensions/tests/Microsoft.Web.Xdt.Extensions.Tests.csproj" />
11561149
</Folder>
1157-
<Folder Name="/src/SiteExtensions/Sdk/">
1158-
<Project Path="src/SiteExtensions/Sdk/HostingStartup/HostingStartup.csproj" />
1159-
</Folder>
11601150
<Folder Name="/src/Testing/">
11611151
<Project Path="src/Analyzers/Microsoft.AspNetCore.Analyzer.Testing/src/Microsoft.AspNetCore.Analyzer.Testing.csproj" />
11621152
</Folder>
@@ -1227,6 +1217,7 @@
12271217
<Project Path="src/Caching/perf/MicroBenchmarks/Microsoft.Extensions.Caching.MicroBenchmarks/Microsoft.Extensions.Caching.MicroBenchmarks.csproj" />
12281218
<Project Path="src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter/src/Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj" />
12291219
<Project Path="src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid.csproj" />
1220+
<Project Path="src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/test/Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj" />
12301221
<Project Path="src/Components/WebView/test/E2ETest/Microsoft.AspNetCore.Components.WebViewE2E.Test.csproj" />
12311222
<Project Path="src/DataProtection/samples/KeyManagementSimulator/KeyManagementSimulator.csproj" />
12321223
<Project Path="src/Framework/AspNetCoreAnalyzers/samples/WebAppSample/WebAppSample.csproj" />

eng/Version.Details.xml

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

eng/Versions.props

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

global.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "10.0.100-preview.6.25315.102"
3+
"version": "10.0.100-preview.7.25322.101"
44
},
55
"tools": {
6-
"dotnet": "10.0.100-preview.6.25315.102",
6+
"dotnet": "10.0.100-preview.7.25322.101",
77
"runtimes": {
88
"dotnet/x86": [
99
"$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)"
@@ -27,9 +27,9 @@
2727
"jdk": "latest"
2828
},
2929
"msbuild-sdks": {
30-
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25351.105",
31-
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25351.105",
32-
"Microsoft.DotNet.SharedFramework.Sdk": "10.0.0-beta.25351.105",
30+
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25358.102",
31+
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25358.102",
32+
"Microsoft.DotNet.SharedFramework.Sdk": "10.0.0-beta.25358.102",
3333
"Microsoft.Build.NoTargets": "3.7.0",
3434
"Microsoft.Build.Traversal": "3.4.0"
3535
}

src/Components/Components.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"src\\Components\\Forms\\test\\Microsoft.AspNetCore.Components.Forms.Tests.csproj",
2020
"src\\Components\\QuickGrid\\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter\\src\\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj",
2121
"src\\Components\\QuickGrid\\Microsoft.AspNetCore.Components.QuickGrid\\src\\Microsoft.AspNetCore.Components.QuickGrid.csproj",
22+
"src\\Components\\QuickGrid\\Microsoft.AspNetCore.Components.QuickGrid\\test\\Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj",
2223
"src\\Components\\Samples\\BlazorServerApp\\BlazorServerApp.csproj",
2324
"src\\Components\\Samples\\BlazorUnitedApp.Client\\BlazorUnitedApp.Client.csproj",
2425
"src\\Components\\Samples\\BlazorUnitedApp\\BlazorUnitedApp.csproj",

src/Components/Components/src/PersistentStateValueProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal sealed class PersistentStateValueProvider(PersistentComponentState stat
1919
{
2020
private static readonly ConcurrentDictionary<(string, string, string), byte[]> _keyCache = new();
2121
private static readonly ConcurrentDictionary<(Type, string), PropertyGetter> _propertyGetterCache = new();
22-
private readonly ConcurrentDictionary<Type, IPersistentComponentStateSerializer?> _serializerCache = new();
22+
private static readonly ConcurrentDictionary<Type, IPersistentComponentStateSerializer?> _serializerCache = new();
2323

2424
private readonly Dictionary<ComponentState, PersistingComponentStateSubscription> _subscriptions = [];
2525

src/Components/Endpoints/src/Forms/EndpointAntiforgeryStateProvider.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ namespace Microsoft.AspNetCore.Components.Endpoints.Forms;
1010
internal class EndpointAntiforgeryStateProvider(IAntiforgery antiforgery) : DefaultAntiforgeryStateProvider()
1111
{
1212
private HttpContext? _context;
13+
private bool _canGenerateToken;
1314

1415
internal void SetRequestContext(HttpContext context)
1516
{
1617
_context = context;
18+
_canGenerateToken = true;
1719
}
1820

1921
public override AntiforgeryRequestToken? GetAntiforgeryToken()
@@ -24,17 +26,23 @@ internal void SetRequestContext(HttpContext context)
2426
return _currentToken;
2527
}
2628

27-
// We already have a callback setup to generate the token when the response starts if needed.
28-
// If we need the tokens before we start streaming the response, we'll generate and store them;
29-
// otherwise we'll just retrieve them.
30-
// In case there are no tokens available, we are going to return null and no-op.
31-
var tokens = !_context.Response.HasStarted ? antiforgery.GetAndStoreTokens(_context) : antiforgery.GetTokens(_context);
32-
if (tokens.RequestToken is null)
29+
if (_currentToken == null && _canGenerateToken)
3330
{
34-
return null;
31+
// We already have a callback setup to generate the token when the response starts if needed.
32+
// If we need the tokens before we start streaming the response, we'll generate and store them;
33+
// otherwise we'll just retrieve them.
34+
// In case there are no tokens available, we are going to return null and no-op.
35+
var tokens = !_context.Response.HasStarted ? antiforgery.GetAndStoreTokens(_context) : antiforgery.GetTokens(_context);
36+
if (tokens.RequestToken is null)
37+
{
38+
return null;
39+
}
40+
41+
_currentToken = new AntiforgeryRequestToken(tokens.RequestToken, tokens.FormFieldName);
3542
}
3643

37-
_currentToken = new AntiforgeryRequestToken(tokens.RequestToken, tokens.FormFieldName);
3844
return _currentToken;
3945
}
46+
47+
internal void DisableTokenGeneration() => _canGenerateToken = false;
4048
}

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using System.Text;
77
using System.Text.Encodings.Web;
88
using Microsoft.AspNetCore.Antiforgery;
9+
using Microsoft.AspNetCore.Components.Endpoints.Forms;
910
using Microsoft.AspNetCore.Components.Endpoints.Rendering;
11+
using Microsoft.AspNetCore.Components.Forms;
1012
using Microsoft.AspNetCore.Components.Infrastructure;
1113
using Microsoft.AspNetCore.Diagnostics;
1214
using Microsoft.AspNetCore.Http;
@@ -76,14 +78,6 @@ private async Task RenderComponentCore(HttpContext context)
7678
return;
7779
}
7880

79-
context.Response.OnStarting(() =>
80-
{
81-
// Generate the antiforgery tokens before we start streaming the response, as it needs
82-
// to set the cookie header.
83-
antiforgery!.GetAndStoreTokens(context);
84-
return Task.CompletedTask;
85-
});
86-
8781
if (httpActivityContext != default)
8882
{
8983
_activityLinkStore.SetActivityContext(ComponentsActivityLinkStore.Http, httpActivityContext, null);
@@ -143,8 +137,17 @@ await _renderer.InitializeStandardComponentServicesAsync(
143137
var bufferingFeature = context.Features.GetRequiredFeature<IHttpResponseBodyFeature>();
144138
bufferingFeature.DisableBuffering();
145139

140+
// Store the tokens if not emitted already in case we stream a form in the response.
141+
antiforgery!.GetAndStoreTokens(context);
142+
146143
context.Response.Headers.ContentEncoding = "identity";
147144
}
145+
else if (endpoint.Metadata.GetMetadata<ConfiguredRenderModesMetadata>()?.ConfiguredRenderModes.Length == 0)
146+
{
147+
// Disable token generation on EndpointAntiforgeryStateProvider if we are not streaming.
148+
var provider = (EndpointAntiforgeryStateProvider)context.RequestServices.GetRequiredService<AntiforgeryStateProvider>();
149+
provider.DisableTokenGeneration();
150+
}
148151

149152
// Importantly, we must not yield this thread (which holds exclusive access to the renderer sync context)
150153
// in between the first call to htmlContent.WriteTo and the point where we start listening for subsequent

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Columns/GridSort.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,16 @@ private List<SortedProperty> BuildPropertyList(bool ascending)
135135
// Not sure we really want this level of complexity, but it converts expressions like @(c => c.Medals.Gold) to "Medals.Gold"
136136
private static string ToPropertyName(LambdaExpression expression)
137137
{
138-
if (expression.Body is not MemberExpression body)
138+
var expressionBody = expression.Body;
139+
140+
// Handle UnaryExpressions that can occur due to implicit conversions, such as nullable value types
141+
if (expressionBody.NodeType == ExpressionType.Convert ||
142+
expressionBody.NodeType == ExpressionType.ConvertChecked)
143+
{
144+
expressionBody = ((UnaryExpression)expressionBody).Operand;
145+
}
146+
147+
if (expressionBody is not MemberExpression body)
139148
{
140149
throw new ArgumentException(ExpressionNotRepresentableMessage);
141150
}

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@
2323
<Reference Include="Microsoft.AspNetCore.Components.Web" />
2424
</ItemGroup>
2525

26+
<ItemGroup>
27+
<InternalsVisibleTo Include="Microsoft.AspNetCore.Components.QuickGrid.Tests" />
28+
</ItemGroup>
29+
2630
</Project>

0 commit comments

Comments
 (0)