diff --git a/src/Http/Routing/src/Matching/ILEmitTrieFactory.cs b/src/Http/Routing/src/Matching/ILEmitTrieFactory.cs index 52af625d63c8..01f40f130c79 100644 --- a/src/Http/Routing/src/Matching/ILEmitTrieFactory.cs +++ b/src/Http/Routing/src/Matching/ILEmitTrieFactory.cs @@ -4,6 +4,7 @@ #nullable disable using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -12,6 +13,7 @@ namespace Microsoft.AspNetCore.Routing.Matching; +[RequiresDynamicCode("ILEmitTrieFactory uses runtime IL generation.")] internal static class ILEmitTrieFactory { // 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 public Label ReturnNotAscii { get; set; } } + [RequiresDynamicCode("ILEmitTrieFactory uses runtime IL generation.")] private sealed class Methods { // Caching because the methods won't change, if we're being called once we're likely to diff --git a/src/Http/Routing/src/Matching/ILEmitTrieJumpTable.cs b/src/Http/Routing/src/Matching/ILEmitTrieJumpTable.cs index f382c2d562b7..b0e975d7fdc1 100644 --- a/src/Http/Routing/src/Matching/ILEmitTrieJumpTable.cs +++ b/src/Http/Routing/src/Matching/ILEmitTrieJumpTable.cs @@ -3,12 +3,15 @@ #nullable disable +using System.Diagnostics.CodeAnalysis; + namespace Microsoft.AspNetCore.Routing.Matching; // Uses generated IL to implement the JumpTable contract. This approach requires // a fallback jump table for two reasons: // 1. We compute the IL lazily to avoid taking up significant time when processing a request // 2. The generated IL only supports ASCII in the URL path +[RequiresDynamicCode("ILEmitTrieJumpTable uses runtime IL generation.")] internal sealed class ILEmitTrieJumpTable : JumpTable { private readonly int _defaultDestination; diff --git a/src/Http/Routing/src/Matching/JumpTableBuilder.cs b/src/Http/Routing/src/Matching/JumpTableBuilder.cs index 4ead4b3bb889..0c48d3b261c2 100644 --- a/src/Http/Routing/src/Matching/JumpTableBuilder.cs +++ b/src/Http/Routing/src/Matching/JumpTableBuilder.cs @@ -87,7 +87,9 @@ public static JumpTable Build(int defaultDestination, int exitDestination, (stri // Use the ILEmitTrieJumpTable if the IL is going to be compiled (not interpreted) if (RuntimeFeature.IsDynamicCodeCompiled) { +#pragma warning disable IL3050 // See https://github.com/dotnet/linker/issues/2715. return new ILEmitTrieJumpTable(defaultDestination, exitDestination, pathEntries, vectorize: null, fallback); +#pragma warning restore IL3050 } return fallback;