diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs index a64f098a6610d..4e4ead63ba934 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs @@ -15,6 +15,8 @@ namespace System.Text.RegularExpressions /// /// RegexCompiler translates a block of RegexCode to MSIL, and creates a subclass of the RegexRunner type. /// + [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", + Justification = "Native AOT does not use compiled Regex")] internal abstract class RegexCompiler { private static readonly FieldInfo s_runtextstartField = RegexRunnerField("runtextstart"); diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs index 0a1ab21806263..e246c1702315d 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Reflection; using System.Reflection.Emit; +using System.Diagnostics.CodeAnalysis; namespace System.Text.RegularExpressions { @@ -65,6 +66,8 @@ internal sealed class RegexLWCGCompiler : RegexCompiler } /// Begins the definition of a new method (no args) with a specified return value. + [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", + Justification = "Native AOT does not use compiled Regex")] private DynamicMethod DefineDynamicMethod(string methname, Type? returntype, Type hostType, Type[] paramTypes) { // We're claiming that these are static methods, but really they are instance methods.