Description
The reflection tests ConstructorInfoTests.Invoke_StringConstructorWithExistingInstance and Invoke_ArrayConstructorWithExistingInstance are currently limited to CoreCLR because Mono does not support invoking string and array pseudo-constructors against existing objects.
Mono should match the expected reflection behavior for these constructor handles. The tests exercise the existing-object path and expect the runtime's documented NotSupportedException behavior to be surfaced through TargetInvocationException.
Reproduction Steps
Run these tests from src/libraries/System.Runtime/tests/System.Reflection.Tests/ConstructorInfoTests.cs on Mono:
ConstructorInfo stringConstructor = typeof(string).GetConstructor(new[] { typeof(char[]) })!;
TargetInvocationException stringException = Assert.Throws<TargetInvocationException>(() =>
stringConstructor.Invoke("existing", new object?[] { new[] { 'n', 'e', 'w' } }));
Assert.IsType<NotSupportedException>(stringException.InnerException);
ConstructorInfo arrayConstructor = typeof(object[]).GetConstructor(new[] { typeof(int) })!;
TargetInvocationException arrayException = Assert.Throws<TargetInvocationException>(() =>
arrayConstructor.Invoke(new object[1], new object?[] { 3 }));
Assert.IsType<NotSupportedException>(arrayException.InnerException);
Expected behavior
Both tests pass on Mono with TargetInvocationException wrapping NotSupportedException, matching CoreCLR.
Actual behavior
These constructor-on-existing-object cases are not currently supported on Mono, so the tests are guarded to CoreCLR.
Regression?
Unknown.
Known Workarounds
None.
Configuration
Mono runtime; System.Reflection.Tests.
Other information
Relevant tests: src/libraries/System.Runtime/tests/System.Reflection.Tests/ConstructorInfoTests.cs.
[!NOTE] This issue was filed with assistance from GitHub Copilot.
Description
The reflection tests
ConstructorInfoTests.Invoke_StringConstructorWithExistingInstanceandInvoke_ArrayConstructorWithExistingInstanceare currently limited to CoreCLR because Mono does not support invoking string and array pseudo-constructors against existing objects.Mono should match the expected reflection behavior for these constructor handles. The tests exercise the existing-object path and expect the runtime's documented
NotSupportedExceptionbehavior to be surfaced throughTargetInvocationException.Reproduction Steps
Run these tests from
src/libraries/System.Runtime/tests/System.Reflection.Tests/ConstructorInfoTests.cson Mono:Expected behavior
Both tests pass on Mono with
TargetInvocationExceptionwrappingNotSupportedException, matching CoreCLR.Actual behavior
These constructor-on-existing-object cases are not currently supported on Mono, so the tests are guarded to CoreCLR.
Regression?
Unknown.
Known Workarounds
None.
Configuration
Mono runtime;
System.Reflection.Tests.Other information
Relevant tests:
src/libraries/System.Runtime/tests/System.Reflection.Tests/ConstructorInfoTests.cs.