Skip to content

Commit 97e26bd

Browse files
authored
[AOT] Add RequiresDynamicCode annotation to Microsoft.AspNetCore.Routing (#45580)
* Add warnings and annotations * revert PropertyHelper changes * Revert JSInterop changes * revert PropertySetter changes
1 parent 1099d06 commit 97e26bd

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/Http/Routing/src/Matching/ILEmitTrieFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable disable
55

66
using System.Diagnostics;
7+
using System.Diagnostics.CodeAnalysis;
78
using System.Linq;
89
using System.Reflection;
910
using System.Reflection.Emit;
@@ -12,6 +13,7 @@
1213

1314
namespace Microsoft.AspNetCore.Routing.Matching;
1415

16+
[RequiresDynamicCode("ILEmitTrieFactory uses runtime IL generation.")]
1517
internal static class ILEmitTrieFactory
1618
{
1719
// The algorthm we use only works for ASCII text. If we find non-ASCII text in the input
@@ -477,6 +479,7 @@ private sealed class Labels
477479
public Label ReturnNotAscii { get; set; }
478480
}
479481

482+
[RequiresDynamicCode("ILEmitTrieFactory uses runtime IL generation.")]
480483
private sealed class Methods
481484
{
482485
// Caching because the methods won't change, if we're being called once we're likely to

src/Http/Routing/src/Matching/ILEmitTrieJumpTable.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33

44
#nullable disable
55

6+
using System.Diagnostics.CodeAnalysis;
7+
68
namespace Microsoft.AspNetCore.Routing.Matching;
79

810
// Uses generated IL to implement the JumpTable contract. This approach requires
911
// a fallback jump table for two reasons:
1012
// 1. We compute the IL lazily to avoid taking up significant time when processing a request
1113
// 2. The generated IL only supports ASCII in the URL path
14+
[RequiresDynamicCode("ILEmitTrieJumpTable uses runtime IL generation.")]
1215
internal sealed class ILEmitTrieJumpTable : JumpTable
1316
{
1417
private readonly int _defaultDestination;

src/Http/Routing/src/Matching/JumpTableBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public static JumpTable Build(int defaultDestination, int exitDestination, (stri
8787
// Use the ILEmitTrieJumpTable if the IL is going to be compiled (not interpreted)
8888
if (RuntimeFeature.IsDynamicCodeCompiled)
8989
{
90+
#pragma warning disable IL3050 // See https://github.com/dotnet/linker/issues/2715.
9091
return new ILEmitTrieJumpTable(defaultDestination, exitDestination, pathEntries, vectorize: null, fallback);
92+
#pragma warning restore IL3050
9193
}
9294

9395
return fallback;

0 commit comments

Comments
 (0)