Skip to content

Commit f7472c8

Browse files
authored
Adding SignalR CustomAwaitable feature switch (#41832)
This is the SDK portion of changes needed to make SignalR compatible with native AOT. See dotnet/aspnetcore#56460.
1 parent a87bd46 commit f7472c8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/WebSdk/ProjectSystem/Targets/Microsoft.NET.Sdk.Web.ProjectSystem.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Copyright (c) .NET Foundation. All rights reserved.
5757
<!-- Enable the built-in source generators. -->
5858
<EnableRequestDelegateGenerator Condition="'$(EnableRequestDelegateGenerator)' == ''">true</EnableRequestDelegateGenerator>
5959
<EnableConfigurationBindingGenerator Condition="'$(EnableConfigurationBindingGenerator)' == ''">true</EnableConfigurationBindingGenerator>
60+
61+
<!-- Default feature switch values for trimmed apps. -->
62+
<SignalRCustomAwaitableSupport Condition="'$(SignalRCustomAwaitableSupport)' == ''">false</SignalRCustomAwaitableSupport>
6063
</PropertyGroup>
6164

6265
<PropertyGroup>

src/WebSdk/Web/Targets/Sdk.Server.targets

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,19 @@ Copyright (c) .NET Foundation. All rights reserved.
3131
<Import Sdk="Microsoft.NET.Sdk.Web.ProjectSystem" Project="Sdk.targets" />
3232

3333
<Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.targets" />
34+
35+
<!--
36+
============================================================
37+
DefaultRuntimeHostConfigurationOptions
38+
Defaults @(RuntimeHostConfigurationOption) items based on MSBuild properties.
39+
============================================================
40+
-->
41+
42+
<ItemGroup>
43+
<RuntimeHostConfigurationOption Include="Microsoft.AspNetCore.SignalR.Hub.IsCustomAwaitableSupported"
44+
Condition="'$(SignalRCustomAwaitableSupport)' != ''"
45+
Value="$(SignalRCustomAwaitableSupport)"
46+
Trim="true" />
47+
</ItemGroup>
48+
3449
</Project>

test/Microsoft.NET.Sdk.Web.Tests/PublishTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public void TrimmingOptions_Are_Defaulted_Correctly_On_Trimmed_Apps(string targe
3939
JsonNode runtimeConfig = JsonNode.Parse(runtimeConfigContents);
4040
JsonNode configProperties = runtimeConfig["runtimeOptions"]["configProperties"];
4141

42+
configProperties["Microsoft.AspNetCore.SignalR.Hub.IsCustomAwaitableSupported"].GetValue<bool>()
43+
.Should().BeFalse();
4244
configProperties["System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"].GetValue<bool>()
4345
.Should().BeFalse();
4446
}
@@ -94,6 +96,7 @@ public void TrimmingOptions_Are_Defaulted_Correctly_On_Aot_Apps(string targetFra
9496
string responseFile = Path.Combine(outputDirectory, "native", $"{projectName}.ilc.rsp");
9597
var responseFileContents = File.ReadLines(responseFile);
9698

99+
responseFileContents.Should().Contain("--feature:Microsoft.AspNetCore.SignalR.Hub.IsCustomAwaitableSupported=false");
97100
responseFileContents.Should().Contain("--feature:System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault=false");
98101
responseFileContents.Should().Contain("--feature:System.Diagnostics.Tracing.EventSource.IsSupported=true");
99102
responseFileContents.Should().Contain("--runtimeknob:System.GC.DynamicAdaptationMode=1");

0 commit comments

Comments
 (0)