diff options
author | Eric Erhardt <eric.erhardt@microsoft.com> | 2020-11-11 01:58:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-11 01:58:12 +0300 |
commit | d8cbe373195ed3fc727d12d12eb5923b188a7990 (patch) | |
tree | 93066927e4b277390dd39b834da3d19da61c88dc /test/Mono.Linker.Tests.Cases/DataFlow | |
parent | 1ce464d7c9478fda885ec52c05ac6a7602a6274b (diff) |
Fix ArgumentOutOfRange in GetConstructor scanning (#1621)
With https://github.com/dotnet/runtime/issues/42753, we are adding a new overload to Type.GetConstructor that only takes BindingFlags and Type[].
However, this new overload exposes a bug in the ILLinker where it is using the wrong parameter count to find how many constructor parameters are being used.
Fixing the issue by using the correct parameter count in the switch statement.
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/DataFlow')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs index 0fe6f8104..34e524215 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs @@ -17,6 +17,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow TestGetPublicParameterlessConstructorWithEmptyTypes (); TestGetPublicParameterlessConstructorWithArrayEmpty (); TestGetPublicParameterlessConstructorWithUnknownArray (); + TestGetConstructorOverloads (); } [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetMethod), new Type[] { typeof (string) }, messageCode: "IL2080")] @@ -39,6 +40,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow s_typeWithKeptPublicParameterlessConstructor.GetConstructor (s_localEmptyArrayInvisibleToAnalysis); } + [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetMethod), new Type[] { typeof (string) }, messageCode: "IL2080")] + static void TestGetConstructorOverloads () + { + s_typeWithKeptPublicParameterlessConstructor.GetConstructor (BindingFlags.Public, null, Type.EmptyTypes, null); + s_typeWithKeptPublicParameterlessConstructor.GetConstructor (BindingFlags.Public, null, CallingConventions.Any, Type.EmptyTypes, null); + s_typeWithKeptPublicParameterlessConstructor.GetMethod ("Foo"); + } + static Type[] s_localEmptyArrayInvisibleToAnalysis = Type.EmptyTypes; [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] |