diff --git a/docs/workflow/building/coreclr/nativeaot.md b/docs/workflow/building/coreclr/nativeaot.md index af4be7e7985952..4c9646a76d6d82 100644 --- a/docs/workflow/building/coreclr/nativeaot.md +++ b/docs/workflow/building/coreclr/nativeaot.md @@ -77,6 +77,9 @@ Sometimes it's handy to be able to rebuild the managed test manually or run the For more advanced scenarios, look for at [Building Test Subsets](../../testing/coreclr/windows-test-instructions.md#building-test-subsets) and [Generating Core_Root](../../testing/coreclr/windows-test-instructions.md#generating-core_root) +### Running library tests +Build library tests by passing the `libs.tests` subset together with the `/p:TestNativeAot=true` to build the libraries, i.e. `clr.alljits+clr.tools+clr.nativeaotlibs+clr.nativeaotruntime+libs+libs.tests /p:TestNativeAot=true` together with the full arguments as specified [above](#building). Then, to run a specific library, go to the tests directory of the library and run the usual command to run tests for the library (see [Running tests for a single library](../../testing/libraries/testing.md#running-tests-for-a-single-library)) but add the `/p:TestNativeAot=true`, i.e. `dotnet.cmd build /t:Test /p:TestNativeAot=true`. + ## Design Documentation - [ILC Compiler Architecture](../../../design/coreclr/botr/ilc-architecture.md) diff --git a/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs b/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs index 9c5741413ba55d..e79e6c0b7092c1 100644 --- a/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs +++ b/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs @@ -123,7 +123,22 @@ public sealed override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberIn if (member is null) throw new ArgumentNullException(nameof(member)); - MemberInfo result = member.MemberType switch + // Need to walk up the inheritance chain if member is not found + // Leverage the existing cache mechanism of per type to store members + RuntimeTypeInfo? runtimeType = this; + while (runtimeType != null) + { + MemberInfo result = runtimeType.GetDeclaredMemberWithSameMetadataDefinitionAs(member); + if (result != null) + return result; + runtimeType = runtimeType.BaseType as RuntimeTypeInfo; + } + throw new ArgumentException(SR.Format(SR.Arg_MemberInfoNotFound, member.Name), nameof(member)); + } + + private MemberInfo GetDeclaredMemberWithSameMetadataDefinitionAs(MemberInfo member) + { + return member.MemberType switch { MemberTypes.Method => QueryMemberWithSameMetadataDefinitionAs(member), MemberTypes.Constructor => QueryMemberWithSameMetadataDefinitionAs(member), @@ -133,11 +148,6 @@ public sealed override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberIn MemberTypes.NestedType => QueryMemberWithSameMetadataDefinitionAs(member), _ => null, }; - - if (result is null) - throw new ArgumentException(SR.Format(SR.Arg_MemberInfoNotFound, member.Name), nameof(member)); - - return result; } private M QueryMemberWithSameMetadataDefinitionAs(MemberInfo member) where M : MemberInfo diff --git a/src/libraries/System.Reflection/tests/ConstructorInfoTests.cs b/src/libraries/System.Reflection/tests/ConstructorInfoTests.cs index e6d59b787cc564..c4990637fe85fa 100644 --- a/src/libraries/System.Reflection/tests/ConstructorInfoTests.cs +++ b/src/libraries/System.Reflection/tests/ConstructorInfoTests.cs @@ -115,6 +115,7 @@ public void Invoke_OneDimensionalArray() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/67457", TestRuntimes.Mono)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/69336", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Invoke_OneDimensionalArray_NegativeLengths_ThrowsOverflowException() { ConstructorInfo[] constructors = GetConstructors(typeof(object[])); diff --git a/src/libraries/System.Reflection/tests/TypeInfoTests.cs b/src/libraries/System.Reflection/tests/TypeInfoTests.cs index fb0bccb86c4708..24220a3513662f 100644 --- a/src/libraries/System.Reflection/tests/TypeInfoTests.cs +++ b/src/libraries/System.Reflection/tests/TypeInfoTests.cs @@ -1656,7 +1656,7 @@ private static (Type, Type) CreateGeneratedTypes() } [Theory, MemberData(nameof(GetMemberWithSameMetadataDefinitionAsData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/67533", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/69244", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void GetMemberWithSameMetadataDefinitionAs(Type openGenericType, Type closedGenericType, bool checkDeclaringType) { BindingFlags all = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly; diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index c0f3bfc5dec511..7358913d05ab07 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -379,6 +379,7 @@ +