Repository navigation
Closed
Description
[FAIL] System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(openGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers<>), closedGenericType: typeof(System.Reflection.Tests.TI_TypeDerivedFromGenericTypeWithAllMembers<int>), checkDeclaringType: False)
System.ArgumentException : A MemberInfo that matches 'add_PrivateStaticEvent' could not be found. (Parameter 'member')
at System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.GetMemberWithSameMetadataDefinitionAs(MemberInfo) + 0x154
at System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(Type, Type, Boolean) + 0x70
at System.Reflection.Tests!<BaseAddress>+0x6812ca
at System.InvokeUtils.CallDynamicInvokeMethod(Object, IntPtr, IntPtr, IntPtr, Object, Object[], BinderBundle, Boolean, Boolean) + 0x150
[FAIL] System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(openGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers<>), closedGenericType: typeof(System.Reflection.Tests.TI_TypeDerivedFromGenericTypeWithAllMembersClosed), checkDeclaringType: False)
System.ArgumentException : A MemberInfo that matches 'add_PrivateStaticEvent' could not be found. (Parameter 'member')
at System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.GetMemberWithSameMetadataDefinitionAs(MemberInfo) + 0x154
at System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(Type, Type, Boolean) + 0x70
at System.Reflection.Tests!<BaseAddress>+0x6812ca
at System.InvokeUtils.CallDynamicInvokeMethod(Object, IntPtr, IntPtr, IntPtr, Object, Object[], BinderBundle, Boolean, Boolean) + 0x150
[FAIL] System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(openGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers<>), closedGenericType: typeof(System.Reflection.Tests.TI_TypeDerivedFromGenericTypeWithAllMembers<System.Reflection.Tests.TypeInfoTests+ClassWithMultipleConstructors>), checkDeclaringType: False)
System.ArgumentException : A MemberInfo that matches 'add_PrivateStaticEvent' could not be found. (Parameter 'member')
at System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.GetMemberWithSameMetadataDefinitionAs(MemberInfo) + 0x154
at System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(Type, Type, Boolean) + 0x70
at System.Reflection.Tests!<BaseAddress>+0x6812ca
at System.InvokeUtils.CallDynamicInvokeMethod(Object, IntPtr, IntPtr, IntPtr, Object, Object[], BinderBundle, Boolean, Boolean) + 0x150
[FAIL] System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(openGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers), closedGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers), checkDeclaringType: True)
'add_PrivateStaticEvent' doesn't have the right DeclaringType
Expected: True
Actual: False
at System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(Type, Type, Boolean) + 0x199
at System.Reflection.Tests!<BaseAddress>+0x6812ca
at System.InvokeUtils.CallDynamicInvokeMethod(Object, IntPtr, IntPtr, IntPtr, Object, Object[], BinderBundle, Boolean, Boolean) + 0x150
[FAIL] System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(openGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers<>), closedGenericType: typeof(System.Reflection.Tests.TI_GenericTypeWithAllMembers), checkDeclaringType: True)
'add_PrivateStaticEvent' doesn't have the right DeclaringType
Expected: True
Actual: False
at System.Reflection.Tests.TypeInfoTests.GetMemberWithSameMetadataDefinitionAs(Type, Type, Boolean) + 0x199
at System.Reflection.Tests!<BaseAddress>+0x6812ca
at System.InvokeUtils.CallDynamicInvokeMethod(Object, IntPtr, IntPtr, IntPtr, Object, Object[], BinderBundle, Boolean, Boolean) + 0x150
Activity
LakshanF commentedon Apr 29, 2022
The test is failing from the following scenario as discovered in the PR #67575,
A repro for the first failing scenario with the below call stack (regular .NET app output is also shown below). Specifically, in a scenario like the following,
Repro.txt
.NET program output
LakshanF commentedon May 4, 2022
Looking at a baseline case where enumerating MemberInfo's where the OpenGenericType is d (see above comment) works. Although the only member found is a ctor (not the base's cctor). The output is shown below the program (.NET program output is the same).
Comparing the relevant nodes for these 2 programs (Repro and Baseline) of the relevant types, b and d, using DependencyGraphViewer, did not show any missing nodes although the order of the nodes that were generated in the 2 programs for both types were different.
Baseline.txt
LakshanF commentedon May 5, 2022
The problem seems to be in the reflection code. The CLR code walks up the type hierarchy to find the
MemberInfowhereas native aot doesn't.jkotas commentedon May 10, 2022
The fix was reverted
LakshanF commentedon May 11, 2022
In NativeAOT, when a TypeDelegator is used to wrap a closed generic type, the declared type of its members are no longer RuntimeTypes. The output for .NET and NativeAot for the code snippet is as follows,
.NET
NativeAot
LakshanF commentedon May 12, 2022
Created a separate issue, #69244, to track this