-
Notifications
You must be signed in to change notification settings - Fork 126
Closed
Labels
Milestone
Description
The following code in System.Text.RegularExpressions.RegexCompiler is causing IL2060 warnings:
private static readonly MethodInfo s_memoryMarshalGetReference = typeof(MemoryMarshal).GetMethod("GetReference", new Type[] { typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) })!.MakeGenericMethod(typeof(char));
private static readonly MethodInfo s_spanIndexOf = typeof(MemoryExtensions).GetMethod("IndexOf", new Type[] { typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), Type.MakeGenericMethodParameter(0) })!.MakeGenericMethod(typeof(char));
private static readonly MethodInfo s_spanIndexOfAnyCharChar = typeof(MemoryExtensions).GetMethod("IndexOfAny", new Type[] { typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), Type.MakeGenericMethodParameter(0), Type.MakeGenericMethodParameter(0) })!.MakeGenericMethod(typeof(char));
private static readonly MethodInfo s_spanIndexOfAnyCharCharChar = typeof(MemoryExtensions).GetMethod("IndexOfAny", new Type[] { typeof(ReadOnlySpan<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), Type.MakeGenericMethodParameter(0), Type.MakeGenericMethodParameter(0), Type.MakeGenericMethodParameter(0) })!.MakeGenericMethod(typeof(char));RegexCompiler.cs(59,9): Trim analysis warning IL2060: System.Text.RegularExpressions.RegexCompiler..cctor(): Call to `System.Reflection.MethodInfo.MakeGenericMethod(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [C:\git\runtime\src\libraries\src.proj]
RegexCompiler.cs(60,9): Trim analysis warning IL2060: System.Text.RegularExpressions.RegexCompiler..cctor(): Call to `System.Reflection.MethodInfo.MakeGenericMethod(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [C:\git\runtime\src\libraries\src.proj]
RegexCompiler.cs(61,9): Trim analysis warning IL2060: System.Text.RegularExpressions.RegexCompiler..cctor(): Call to `System.Reflection.MethodInfo.MakeGenericMethod(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [C:\git\runtime\src\libraries\src.proj]
RegexCompiler.cs(62,9): Trim analysis warning IL2060: System.Text.RegularExpressions.RegexCompiler..cctor(): Call to `System.Reflection.MethodInfo.MakeGenericMethod(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [C:\git\runtime\src\libraries\src.proj]
In this case, the ILLinker should be able to discern that the methods being referenced don't have DynamicallyAccessedMembers attributes and it shouldn't cause a warning.
Reactions are currently unavailable