Skip to content

Commit d3b20c9

Browse files
committed
tmp
1 parent 31ea751 commit d3b20c9

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

AspNetCore.sln

+1
Original file line numberDiff line numberDiff line change
@@ -11405,6 +11405,7 @@ Global
1140511405
{9788C76F-658B-4441-88F8-22C6B86FAD27} = {7D2B0799-A634-42AC-AE77-5D167BA51389}
1140611406
{1970D5CD-D9A4-4673-A297-179BB04199F4} = {7D2B0799-A634-42AC-AE77-5D167BA51389}
1140711407
{A40350FE-4334-4007-B1C3-6BEB1B070309} = {7D2B0799-A634-42AC-AE77-5D167BA51389}
11408+
{A40350FE-4334-4007-B1C3-6BEB1B070308} = {6126DCE4-9692-4EE2-B240-C65743572995}
1140811409
{C1E7F837-6988-43E2-9E1C-7302DB484F99} = {017429CC-C5FB-48B4-9C46-034E29EE2F06}
1140911410
{2A91479A-4ABE-4BB7-9A5E-CA3B9CCFC69E} = {C1E7F837-6988-43E2-9E1C-7302DB484F99}
1141011411
{7CB09412-C9B0-47E8-A8C3-311AA4CFDE04} = {C1E7F837-6988-43E2-9E1C-7302DB484F99}

src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyHostBuilder.cs

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Diagnostics.CodeAnalysis;
55
using System.Globalization;
6+
using System.Reflection;
67
using System.Text.Json;
78
using Microsoft.AspNetCore.Components.Forms;
89
using Microsoft.AspNetCore.Components.Infrastructure;
@@ -76,6 +77,8 @@ internal WebAssemblyHostBuilder(
7677
Services = new ServiceCollection();
7778
Logging = new LoggingBuilder(Services);
7879

80+
InitializeRoutingAppContextSwitch();
81+
7982
InitializeWebAssemblyRenderer();
8083

8184
// Retrieve required attributes from JSRuntimeInvoker
@@ -93,6 +96,17 @@ internal WebAssemblyHostBuilder(
9396
};
9497
}
9598

99+
private static InitializeRoutingAppContextSwitch()
100+
{
101+
var value = Assembly.GetEntryAssembly().GetAttributes().OfType<AssemblyMetadataAttribute>()
102+
.Where(ama => string.Equals(ama.Key, "Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport", StringComparison.Ordinal))
103+
.SingleOrDefault()?.Value;
104+
if (value != null && string.Equals(value, "true", StringComparison.OrdinalIgnoreCase))
105+
{
106+
AppContext.SetSwitch("Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport", value);
107+
}
108+
}
109+
96110
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Root components are expected to be defined in assemblies that do not get trimmed.")]
97111
private void InitializeRegisteredRootComponents(IInternalJSImportMethods jsMethods)
98112
{
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
<Project>
22
<PropertyGroup>
33
<BlazorWebAssemblyJSPath>$(MSBuildThisFileDirectory)blazor.webassembly.js</BlazorWebAssemblyJSPath>
4+
<BlazorRoutingEnableRegexConstraint Condition="'$(BlazorRoutingEnableRegexConstraint)' == ''">false</BlazorRoutingEnableRegexConstraint>
45
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<RuntimeHostConfigurationOption Include="Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport"
9+
Condition="'$(BlazorRoutingEnableRegexConstraint)' != ''"
10+
Value="$(BlazorRoutingEnableRegexConstraint)"
11+
Trim="true" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(BlazorRoutingEnableRegexConstraint)' != ''">
16+
<_Parameter1>Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport</_Parameter1>
17+
<_Parameter2>true</_Parameter2>
18+
</AssemblyAttribute>
19+
</ItemGroup>
20+
521
</Project>

src/Components/test/testassets/Components.TestServer/Components.TestServer.csproj

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15+
1516
<RuntimeHostConfigurationOption Include="Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport"
1617
Condition="'$(BlazorRoutingEnableRegexConstraint)' != ''"
1718
Value="$(BlazorRoutingEnableRegexConstraint)"
1819
Trim="true" />
19-
</ItemGroup>
20+
21+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(BlazorRoutingEnableRegexConstraint)' != ''">
22+
<_Parameter1>Microsoft.AspNetCore.Components.Routing.RegexConstraintSupport</_Parameter1>
23+
<_Parameter2>true</_Parameter2>
24+
</AssemblyAttribute>
25+
26+
</ItemGroup>
2027

2128
<ItemGroup>
2229
<Reference Include="Microsoft.AspNetCore" />

0 commit comments

Comments
 (0)