Skip to content

Commit c02ff12

Browse files
authored
Annotate SignalR server for native AOT (#56460)
* Annotate SignalR server for native AOT Fix SignalR Server's usage of MakeGenericMethod when using a streaming reader (IAsyncEnumerable or ChannelReader) following the same approach as the client. Add a runtime check and throw an exception when trying to stream a ValueType in native AOT. Adjust the public annotations: * Remove RequiresUnreferencedCode from AddSignalR * Add RequiresUnreferencedCode to MessagePack and NewtonsoftJson protocols Support trimming and AOT in DefaultHubDispatcher by adding a feature switch to turn off custom awaitable support. Update ObjectMethodExecutor to support trimming and AOT by a new method that doesn't look for custom awaitables, and uses reflection instead of Linq.Expressions. * Fix LinkabilityChecker warnings * Update warning suppressions baseline. * Adjust RequiresDynamicCode annotations * Move RequiresDynamicCode to the whole Hub<T> class, so developers always get a warning when using IHubContext<THub, T>. This helps because THub needs to be a Hub<T>, which will warn as soon as it is used. * Suppress the warning in AddSignalRCore that references HubContext<THub, T> since users will get warnings when they try using IHubContext<THub, T>. * Add more unit tests * Move SignalR server tests down a folder to make room for new tests. * Add trimming test for using typed clients. * Fix tests * Rename the feature switch to IsCustomAwaitableSupported to align with other feature switch naming
1 parent 8046091 commit c02ff12

File tree

71 files changed

+816
-196
lines changed

Some content is hidden

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

71 files changed

+816
-196
lines changed

AspNetCore.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "perf", "perf", "{5095E70C-6
11021102
EndProject
11031103
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Microbenchmarks", "src\SignalR\perf\Microbenchmarks\Microsoft.AspNetCore.SignalR.Microbenchmarks.csproj", "{A6A95BEF-7E21-4D3D-921B-F77267219D27}"
11041104
EndProject
1105-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Tests", "src\SignalR\server\SignalR\test\Microsoft.AspNetCore.SignalR.Tests.csproj", "{4DC9C494-9867-4319-937E-5FBC0E5F5A51}"
1105+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Tests", "src\SignalR\server\SignalR\test\Microsoft.AspNetCore.SignalR.Tests\Microsoft.AspNetCore.SignalR.Tests.csproj", "{4DC9C494-9867-4319-937E-5FBC0E5F5A51}"
11061106
EndProject
11071107
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specification.Tests", "Specification.Tests", "{245939DA-D68D-4B5C-A95E-D3B6923614FF}"
11081108
EndProject

eng/RequiresDelayedBuildProjects.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\IntegrationTestsWebsite\IntegrationTestsWebsite.csproj" />
2222
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\Sandbox\Sandbox.csproj" />
2323
<RequiresDelayedBuild Include="$(RepoRoot)src\ProjectTemplates\test\Templates.Blazor.Tests\Templates.Blazor.Tests.csproj" />
24+
<RequiresDelayedBuild Include="$(RepoRoot)src\SignalR\server\SignalR\test\Microsoft.AspNetCore.SignalR.TrimmingTests\Microsoft.AspNetCore.SignalR.TrimmingTests.proj" />
2425
<RequiresDelayedBuild Include="$(RepoRoot)eng\Npm.Workspace.FunctionalTests.nodeproj" />
2526
</ItemGroup>
2627
</Project>

eng/TrimmableProjects.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
<TrimmableProject Include="Microsoft.AspNetCore.Http.Connections" />
9393
<TrimmableProject Include="Microsoft.AspNetCore.SignalR.Protocols.Json" />
9494
<TrimmableProject Include="Microsoft.AspNetCore.SignalR.Common" />
95+
<TrimmableProject Include="Microsoft.AspNetCore.SignalR.Core" />
96+
<TrimmableProject Include="Microsoft.AspNetCore.SignalR" />
9597
<TrimmableProject Include="Microsoft.AspNetCore.StaticAssets" />
9698
<TrimmableProject Include="Microsoft.AspNetCore.Components.Authorization" />
9799
<TrimmableProject Include="Microsoft.AspNetCore.Components" />

eng/testing/linker/SupportFiles/Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
<ItemGroup>
7474
<ProjectReference Include="$(RepoRoot)src\DefaultBuilder\src\Microsoft.AspNetCore.csproj" />
7575
<ProjectReference Include="$(RepoRoot)src\DataProtection\Extensions\src\Microsoft.AspNetCore.DataProtection.Extensions.csproj" />
76+
<ProjectReference Include="$(RepoRoot)src\SignalR\clients\csharp\Client\src\Microsoft.AspNetCore.SignalR.Client.csproj" />
77+
<ProjectReference Include="$(RepoRoot)src\SignalR\server\SignalR\src\Microsoft.AspNetCore.SignalR.csproj" />
7678
</ItemGroup>
7779

7880
</Project>
Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<linker>
3-
<assembly fullname="Microsoft.AspNetCore.Components, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
4-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
5-
<argument>ILLink</argument>
6-
<argument>IL2026</argument>
7-
<property name="Scope">member</property>
8-
<property name="Target">M:Microsoft.AspNetCore.Components.BindConverter.FormatterDelegateCache.MakeTypeConverterFormatter``1</property>
9-
</attribute>
10-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
11-
<argument>ILLink</argument>
12-
<argument>IL2026</argument>
13-
<property name="Scope">member</property>
14-
<property name="Target">M:Microsoft.AspNetCore.Components.BindConverter.ParserDelegateCache.MakeTypeConverterConverter``1</property>
15-
</attribute>
16-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
17-
<argument>ILLink</argument>
18-
<argument>IL2026</argument>
19-
<property name="Scope">member</property>
20-
<property name="Target">M:Microsoft.AspNetCore.Components.RouteTableFactory.&lt;GetRouteableComponents&gt;g__GetRouteableComponents|4_0(System.Collections.Generic.List{System.Type},System.Reflection.Assembly)</property>
21-
</attribute>
22-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
23-
<argument>ILLink</argument>
24-
<argument>IL2062</argument>
25-
<property name="Scope">member</property>
26-
<property name="Target">M:Microsoft.AspNetCore.Components.RouteTableFactory.Create(System.Collections.Generic.Dictionary{System.Type,System.String[]})</property>
27-
</attribute>
28-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
29-
<argument>ILLink</argument>
30-
<argument>IL2067</argument>
31-
<property name="Scope">member</property>
32-
<property name="Target">M:Microsoft.AspNetCore.Components.CascadingParameterState.CreateReflectedCascadingParameterInfos(System.Type)</property>
33-
</attribute>
3+
<assembly fullname="Microsoft.AspNetCore.Components, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
344
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
355
<argument>ILLink</argument>
366
<argument>IL2072</argument>
@@ -43,47 +13,17 @@
4313
<property name="Scope">member</property>
4414
<property name="Target">M:Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(System.IServiceProvider,Microsoft.AspNetCore.Components.IComponent)</property>
4515
</attribute>
46-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
47-
<argument>ILLink</argument>
48-
<argument>IL2072</argument>
49-
<property name="Scope">member</property>
50-
<property name="Target">M:Microsoft.AspNetCore.Components.DynamicComponent.SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView)</property>
51-
</attribute>
5216
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
5317
<argument>ILLink</argument>
5418
<argument>IL2072</argument>
5519
<property name="Scope">member</property>
5620
<property name="Target">M:Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(Microsoft.AspNetCore.Components.ParameterView@,System.Object)</property>
5721
</attribute>
58-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
59-
<argument>ILLink</argument>
60-
<argument>IL2077</argument>
61-
<property name="Scope">member</property>
62-
<property name="Target">M:Microsoft.AspNetCore.Components.ComponentFactory.CreateInitializer(System.Type)</property>
63-
</attribute>
64-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
65-
<argument>ILLink</argument>
66-
<argument>IL2077</argument>
67-
<property name="Scope">member</property>
68-
<property name="Target">M:Microsoft.AspNetCore.Components.LayoutView.&lt;&gt;c__DisplayClass13_0.&lt;WrapInLayout&gt;g__Render|0(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder)</property>
69-
</attribute>
70-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
71-
<argument>ILLink</argument>
72-
<argument>IL2080</argument>
73-
<property name="Scope">member</property>
74-
<property name="Target">M:Microsoft.AspNetCore.Components.Reflection.MemberAssignment.&lt;GetPropertiesIncludingInherited&gt;d__0.MoveNext</property>
75-
</attribute>
7622
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
7723
<argument>ILLink</argument>
7824
<argument>IL2110</argument>
7925
<property name="Scope">member</property>
8026
<property name="Target">M:Microsoft.AspNetCore.Components.RouteView.Render(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder)</property>
8127
</attribute>
82-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
83-
<argument>ILLink</argument>
84-
<argument>IL2111</argument>
85-
<property name="Scope">member</property>
86-
<property name="Target">M:Microsoft.AspNetCore.Components.RouteView.Render(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder)</property>
87-
</attribute>
8828
</assembly>
8929
</linker>

src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.WarningSuppressions.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<linker>
3-
<assembly fullname="Microsoft.AspNetCore.Http.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
3+
<assembly fullname="Microsoft.AspNetCore.Http.Extensions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
44
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
55
<argument>ILLink</argument>
66
<argument>IL2026</argument>
Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,17 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<linker>
3-
<assembly fullname="Microsoft.JSInterop, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
4-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
5-
<argument>ILLink</argument>
6-
<argument>IL2026</argument>
7-
<property name="Scope">member</property>
8-
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(Microsoft.JSInterop.JSRuntime,Microsoft.JSInterop.Infrastructure.DotNetInvocationInfo,System.String)</property>
9-
</attribute>
10-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
11-
<argument>ILLink</argument>
12-
<argument>IL2026</argument>
13-
<property name="Scope">member</property>
14-
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetDispatcher.EndInvokeDotNetAfterTask(System.Threading.Tasks.Task,Microsoft.JSInterop.JSRuntime,Microsoft.JSInterop.Infrastructure.DotNetInvocationInfo@)</property>
15-
</attribute>
16-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
17-
<argument>ILLink</argument>
18-
<argument>IL2026</argument>
19-
<property name="Scope">member</property>
20-
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetDispatcher.Invoke(Microsoft.JSInterop.JSRuntime,Microsoft.JSInterop.Infrastructure.DotNetInvocationInfo@,System.String)</property>
21-
</attribute>
22-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
23-
<argument>ILLink</argument>
24-
<argument>IL2026</argument>
25-
<property name="Scope">member</property>
26-
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetDispatcher.ParseArguments(Microsoft.JSInterop.JSRuntime,System.String,System.String,System.Type[])</property>
27-
</attribute>
28-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
29-
<argument>ILLink</argument>
30-
<argument>IL2026</argument>
31-
<property name="Scope">member</property>
32-
<property name="Target">M:Microsoft.JSInterop.JSRuntime.EndInvokeJS(System.Int64,System.Boolean,System.Text.Json.Utf8JsonReader@)</property>
33-
</attribute>
34-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
35-
<argument>ILLink</argument>
36-
<argument>IL2026</argument>
37-
<property name="Scope">member</property>
38-
<property name="Target">M:Microsoft.JSInterop.JSRuntime.InvokeAsync``1(System.Int64,System.String,System.Threading.CancellationToken,System.Object[])</property>
39-
</attribute>
40-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
41-
<argument>ILLink</argument>
42-
<argument>IL2055</argument>
43-
<property name="Scope">member</property>
44-
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetObjectReferenceJsonConverterFactory.CreateConverter(System.Type,System.Text.Json.JsonSerializerOptions)</property>
45-
</attribute>
3+
<assembly fullname="Microsoft.JSInterop, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
464
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
475
<argument>ILLink</argument>
486
<argument>IL2065</argument>
497
<property name="Scope">member</property>
508
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetDispatcher.ScanAssemblyForCallableMethods(Microsoft.JSInterop.Infrastructure.DotNetDispatcher.AssemblyKey)</property>
519
</attribute>
52-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
53-
<argument>ILLink</argument>
54-
<argument>IL2091</argument>
55-
<property name="Scope">member</property>
56-
<property name="Target">M:Microsoft.JSInterop.JSObjectReferenceExtensions.&lt;InvokeAsync&gt;d__4`1.MoveNext</property>
57-
</attribute>
58-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
59-
<argument>ILLink</argument>
60-
<argument>IL2091</argument>
61-
<property name="Scope">member</property>
62-
<property name="Target">M:Microsoft.JSInterop.JSRuntime.&lt;InvokeAsync&gt;d__16`1.MoveNext</property>
63-
</attribute>
64-
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
65-
<argument>ILLink</argument>
66-
<argument>IL2091</argument>
67-
<property name="Scope">member</property>
68-
<property name="Target">M:Microsoft.JSInterop.JSRuntimeExtensions.&lt;InvokeAsync&gt;d__4`1.MoveNext</property>
69-
</attribute>
7010
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
7111
<argument>ILLink</argument>
7212
<argument>IL2111</argument>
7313
<property name="Scope">member</property>
7414
<property name="Target">M:Microsoft.JSInterop.Infrastructure.DotNetDispatcher.GetCachedMethodInfo(Microsoft.JSInterop.Infrastructure.IDotNetObjectReference,System.String)</property>
7515
</attribute>
7616
</assembly>
77-
</linker>
17+
</linker>

0 commit comments

Comments
 (0)