Description
The reflection invocation tests for abstract constructors invoked on an existing instance are currently limited to CoreCLR because NativeAOT does not support the behavior exercised by MethodInvokerTests.Constructor_AbstractDeclaringTypeWithExistingInstance, Constructor_AbstractDeclaringTypeWithExistingInstance_RegularArguments, and Constructor_AbstractDeclaringTypeWithExistingInstance_ManyRegularArguments.
NativeAOT should support invoking an instance constructor declared on an abstract base type against an existing compatible derived object, including regular and by-ref argument paths.
Reproduction Steps
Run the System.Reflection.Tests tests listed above on NativeAOT. The tests are currently marked ConditionalFact(IsCoreCLR) and should become active on NativeAOT once the behavior is implemented.
Representative pattern:
ConstructorInfo constructor = typeof(AbstractRegularConstructorTarget).GetConstructor(
BindingFlags.Instance | BindingFlags.NonPublic,
binder: null,
new[] { typeof(int) },
modifiers: null)!;
MethodInvoker invoker = MethodInvoker.Create(constructor);
var target = new ConcreteRegularConstructorTarget(0);
invoker.Invoke(target, 42);
Expected behavior
The constructor runs against the existing derived instance and updates its state, as it does on CoreCLR. Allocating an instance for an abstract declaring type and invoking with a null target should remain rejected.
Actual behavior
The behavior is not currently supported on NativeAOT, so these tests cannot run there and are guarded to CoreCLR.
Regression?
Unknown.
Known Workarounds
None.
Configuration
NativeAOT runtime; System.Reflection.Tests.
Other information
Relevant tests: src/libraries/System.Runtime/tests/System.Reflection.Tests/MethodInvokerTests.cs.
[!NOTE] This issue was filed with assistance from GitHub Copilot.
Description
The reflection invocation tests for abstract constructors invoked on an existing instance are currently limited to CoreCLR because NativeAOT does not support the behavior exercised by
MethodInvokerTests.Constructor_AbstractDeclaringTypeWithExistingInstance,Constructor_AbstractDeclaringTypeWithExistingInstance_RegularArguments, andConstructor_AbstractDeclaringTypeWithExistingInstance_ManyRegularArguments.NativeAOT should support invoking an instance constructor declared on an abstract base type against an existing compatible derived object, including regular and by-ref argument paths.
Reproduction Steps
Run the
System.Reflection.Teststests listed above on NativeAOT. The tests are currently markedConditionalFact(IsCoreCLR)and should become active on NativeAOT once the behavior is implemented.Representative pattern:
Expected behavior
The constructor runs against the existing derived instance and updates its state, as it does on CoreCLR. Allocating an instance for an abstract declaring type and invoking with a null target should remain rejected.
Actual behavior
The behavior is not currently supported on NativeAOT, so these tests cannot run there and are guarded to CoreCLR.
Regression?
Unknown.
Known Workarounds
None.
Configuration
NativeAOT runtime;
System.Reflection.Tests.Other information
Relevant tests:
src/libraries/System.Runtime/tests/System.Reflection.Tests/MethodInvokerTests.cs.