Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move GetMethodType validation method at original order
  • Loading branch information
BartoszKlonowski committed Jul 26, 2021
commit 863b984cfd1a2e78a2aa4afa60d937225c3e6c4b
Original file line number Diff line number Diff line change
Expand Up @@ -1835,27 +1835,6 @@ public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] nam
return generic_params;
}

private static bool IsValidGetMethodType(Type type)
{
if (type is TypeBuilder || type is TypeBuilderInstantiation)
return true;
/*GetMethod() must work with TypeBuilders after CreateType() was called.*/
if (type.Module is ModuleBuilder)
return true;
if (type.IsGenericParameter)
return false;

Type[] inst = type.GetGenericArguments();
if (inst == null)
return false;
for (int i = 0; i < inst.Length; ++i)
{
if (IsValidGetMethodType(inst[i]))
return true;
}
return false;
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern",
Justification = "Linker thinks Type.GetConstructor(ConstructorInfo) is one of the public APIs because it doesn't analyze method signatures. We already have ConstructorInfo.")]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern",
Expand Down Expand Up @@ -1889,6 +1868,27 @@ public static ConstructorInfo GetConstructor(Type type, ConstructorInfo construc
return res;
}

private static bool IsValidGetMethodType(Type type)
{
if (type is TypeBuilder || type is TypeBuilderInstantiation)
return true;
/*GetMethod() must work with TypeBuilders after CreateType() was called.*/
if (type.Module is ModuleBuilder)
return true;
if (type.IsGenericParameter)
return false;

Type[] inst = type.GetGenericArguments();
if (inst == null)
return false;
for (int i = 0; i < inst.Length; ++i)
{
if (IsValidGetMethodType(inst[i]))
return true;
}
return false;
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern",
Justification = "Type.MakeGenericType is used to create a typical instantiation")]
public static MethodInfo GetMethod(Type type, MethodInfo method)
Expand Down