The reflection patterns couldn't be statically analyzed.
Needed to unblock #70201. NativeAOT trims by default and CoreLib is marked trimmable.
private static readonly NullabilityInfoContext nullabilityContext = new NullabilityInfoContext();
private static readonly Type testType = typeof(TypeWithNotNullContext);
private static readonly Type genericType = typeof(GenericTest<TypeWithNotNullContext>);
- private static readonly Type stringType = typeof(string);
- private static readonly BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
+ private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
public static IEnumerable<object[]> FieldTestData()
{
[MemberData(nameof(StringTypeTestData))]
public void NullablePublicOnlyStringTypeTest(string methodName, NullabilityState param1State, NullabilityState param2State, NullabilityState param3State, Type[] types)
{
- ParameterInfo[] parameters = stringType.GetMethod(methodName, flags, types)!.GetParameters();
+ ParameterInfo[] parameters = typeof(string).GetMethod(methodName, flags, types)!.GetParameters();
NullabilityInfo param1 = nullabilityContext.Create(parameters[0]);
NullabilityInfo param2 = nullabilityContext.Create(parameters[1]);
NullabilityInfo param3 = nullabilityContext.Create(parameters[2]);
// The .NET Foundation licenses this file to you under the MIT license.
using System.Buffers;
+using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Reflection;
using System.Runtime.InteropServices;
}
}
+ [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
private static Type GetAsciiUtilityType()
{
- return typeof(object).Assembly.GetType("System.Text.ASCIIUtility");
+ return Type.GetType("System.Text.ASCIIUtility, System.Private.CoreLib");
}
private sealed class UnsafeLazyDelegate<TDelegate> where TDelegate : Delegate
// The .NET Foundation licenses this file to you under the MIT license.
using System.Buffers;
+using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Reflection;
using System.Runtime.InteropServices;
}
}
+ [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
private static Type GetLatin1UtilityType()
{
- return typeof(object).Assembly.GetType("System.Text.Latin1Utility");
+ return Type.GetType("System.Text.Latin1Utility, System.Private.CoreLib");
}
private sealed class UnsafeLazyDelegate<TDelegate> where TDelegate : class
{
return new Lazy<GetPointerToFirstInvalidCharDel>(() =>
{
- Type utf16UtilityType = typeof(Utf8).Assembly.GetType("System.Text.Unicode.Utf16Utility");
+ Type utf16UtilityType = Type.GetType("System.Text.Unicode.Utf16Utility, System.Private.CoreLib");
if (utf16UtilityType is null)
{
{
return new Lazy<GetPointerToFirstInvalidByteDel>(() =>
{
- Type utf8UtilityType = typeof(Utf8).Assembly.GetType("System.Text.Unicode.Utf8Utility");
+ Type utf8UtilityType = Type.GetType("System.Text.Unicode.Utf8Utility, System.Private.CoreLib");
if (utf8UtilityType is null)
{