Skip to content

Commit 29bbab4

Browse files
Copilotsbomerjtschuster
authored
Add intrinsic test for new Type.GetMethod overload (#118003)
Add test for a new Type.GetMethod overload with genericParameterCount, BindingFlags, and Type[] which was already covered by the existing intrinsics logic. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: sbomer <[email protected]> Co-authored-by: Sven Boemer <[email protected]> Co-authored-by: Jackson Schuster <[email protected]>
1 parent 6bc502f commit 29bbab4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/tools/illink/src/ILLink.Shared/TrimAnalysis/HandleCallAction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ ValueWithDynamicallyAccessedMembers valueWithDynamicallyAccessedMembers
582582
// GetMethod(string, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])
583583
// GetMethod(string, int, Type[])
584584
// GetMethod(string, int, Type[], ParameterModifier[]?)
585+
// GetMethod(string, int, BindingFlags, Type[])
585586
// GetMethod(string, int, BindingFlags, Binder?, Type[], ParameterModifier[]?)
586587
// GetMethod(string, int, BindingFlags, Binder?, CallingConventions, Type[], ParameterModifier[]?)
587588
//

src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/MethodUsedViaReflection.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static void Main()
3030
GetMethod_Name_BindingAttr_Types.TestNameBindingFlagsAndTypes();
3131
GetMethod_Name_GenericParameterCount_Types.TestNameWithIntAndType();
3232
GetMethod_Name_GenericParameterCount_Types_Modifiers.TestNameWithIntAndTypeAndModifiers();
33+
GetMethod_Name_GenericParameterCount_BindingAttr_Types.TestNameWithIntAndBindingFlagsAndTypes();
3334
GetMethod_Name_GenericParameterCount_BindingAttr_Binder_Types_Modifiers.TestNameWithIntAndBindingFlags();
3435
GetMethod_Name_GenericParameterCount_BindingAttr_Binder_Types_Modifiers_PrivateBinding.TestNameWithIntAndPrivateBindingFlags();
3536
GetMethod_Name_GenericParameterCount_BindingAttr_Binder_CallConvention_Types_Modifiers.TestNameWithIntBindingFlagsCallingConventionParameter();
@@ -486,6 +487,42 @@ public static void TestNameWithIntAndTypeAndModifiers()
486487
}
487488
}
488489

490+
// GetMethod(string name, int genericParameterCount, BindingFlags bindingAttr, Type[] types)
491+
[Kept]
492+
class GetMethod_Name_GenericParameterCount_BindingAttr_Types
493+
{
494+
private static int OnlyCalledViaReflection()
495+
{
496+
return 42;
497+
}
498+
private int OnlyCalledViaReflection(int foo)
499+
{
500+
return 43;
501+
}
502+
[Kept]
503+
public int OnlyCalledViaReflection(int foo, int bar)
504+
{
505+
return 44;
506+
}
507+
[Kept]
508+
public static int OnlyCalledViaReflection(int foo, int bar, int baz)
509+
{
510+
return 45;
511+
}
512+
[Kept]
513+
public static int OnlyCalledViaReflection(string foo, string bar)
514+
{
515+
return 46;
516+
}
517+
518+
[Kept]
519+
public static void TestNameWithIntAndBindingFlagsAndTypes()
520+
{
521+
var method = typeof(GetMethod_Name_GenericParameterCount_BindingAttr_Types).GetMethod("OnlyCalledViaReflection", 1, BindingFlags.Public, new Type[] { typeof(int) });
522+
method.Invoke(null, new object[] { });
523+
}
524+
}
525+
489526
// GetMethod(string name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
490527
[Kept]
491528
class GetMethod_Name_GenericParameterCount_BindingAttr_Binder_Types_Modifiers

0 commit comments

Comments
 (0)