Repository navigation
Closed
Labels
Milestone
Description
In NativeAOT, a type wrapped in TypeDelegator has issues with its members parent type.
The data passed for this test scenario fails due to this. A simple repro is shown below with the output from .NET and NativeAOT
using System;
using System.Reflection;
public class Program
{
static void Main(string[] args)
{
BindingFlags all = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly;
Type t1 = new TypeDelegator(typeof(U_T<>));
// Type t1 = typeof(U_T<>); //commenting this in and commenting the above line out will make the repro works as .NET
var m1 = t1.GetMembers(all)[0];
Console.WriteLine($"(t1): <{t1.Name}>");
Console.WriteLine($"MemberInfo (m1): <{m1.Name}>");
Console.WriteLine($"m1.DeclaringType.Equals(t1): <{m1.DeclaringType.Equals(t1)}>");
Console.WriteLine($"t1.GetType().FullName: <{t1.GetType().FullName}>");
Console.WriteLine($"t1.UnderlyingSystemType.GetType().FullName: <{t1.UnderlyingSystemType.GetType().FullName}>");
Console.WriteLine($"m1.DeclaringType.GetType().FullName: <{m1.DeclaringType.GetType().FullName}>");
Console.WriteLine($"m1.DeclaringType.UnderlyingSystemType.GetType().FullName: <{m1.DeclaringType.UnderlyingSystemType.GetType().FullName}>");
}
public class U_T<T>
{
}
}NativeAOT Output
(t1): <U_T`1>
MemberInfo (m1): <.ctor>
m1.DeclaringType.Equals(t1): <False>
t1.GetType().FullName: <System.Reflection.TypeDelegator>
t1.UnderlyingSystemType.GetType().FullName: <$BlockedFromReflection_0_c437915f>
m1.DeclaringType.GetType().FullName: <$BlockedFromReflection_0_c437915f>
m1.DeclaringType.UnderlyingSystemType.GetType().FullName: <$BlockedFromReflection_0_c437915f>
,NET Output
(t1): <U_T`1>
MemberInfo (m1): <.ctor>
m1.DeclaringType.Equals(t1): <True>
t1.GetType().FullName: <System.Reflection.TypeDelegator>
t1.UnderlyingSystemType.GetType().FullName: <System.RuntimeType>
m1.DeclaringType.GetType().FullName: <System.RuntimeType>
m1.DeclaringType.UnderlyingSystemType.GetType().FullName: <System.RuntimeType>
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
Enable GetMemberWithSameMetadataDefinitionAs test on native AOT
Enable GetMemberWithSameMetadataDefinitionAs test on native AOT (#119083