Skip to content

Match CoreCLR behavior for NativeAOT string and array constructor invocation - #135287

Merged
jkotas merged 4 commits into
mainfrom
copilot/support-string-array-constructors
Nov 4, 2026
Merged

jkotas merged 4 commits into
mainfrom
copilot/support-string-array-constructors

Conversation

Copilot AI commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

NativeAOT currently ignores the existing object when invoking string or array pseudo-constructors. CoreCLR instead surfaces NotSupportedException through TargetInvocationException.

  • Implementation: Reject an existing target after argument validation, preserving exception wrapping.
  • Coverage: Enable the existing string and array constructor tests on NativeAOT; retain their Mono exclusions.

Note

This description was generated with GitHub Copilot.

@azure-pipelines

azure-pipelines Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@jkotas
jkotas marked this pull request as ready for review November 3, 2026 03:57
@jkotas
jkotas requested a balanced review from Copilot November 3, 2026 03:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change aligning NativeAOT’s existing-instance pseudo-constructor behavior with CoreCLR.

No open issues 🎉

What changed in this PR

Aligns NativeAOT with CoreCLR when reflection invokes string or array pseudo-constructors on an existing object, addressing #134900.

Changes:

  • Rejects existing targets with NotSupportedException while preserving exception wrapping.
  • Enables the existing regression tests on NativeAOT and retains their Mono exclusions.
File Description
src/​libraries/​System.Runtime/​tests/​System.Reflection.Tests/​ConstructorInfoTests.cs Removes NativeAOT exclusions from both existing-instance constructor tests.
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​System/​Reflection/​Runtime/​MethodInfos/​CustomMethodInvoker.cs Rejects existing string and array targets inside the exception-wrapping block.

Review effort: Balanced

@jkotas

jkotas commented Nov 3, 2026

Copy link
Copy Markdown
Member

@MichalStrehovsky PTLA

@jkotas
jkotas merged commit aff3401 into main Nov 4, 2026
123 of 125 checks passed
@jkotas
jkotas deleted the copilot/support-string-array-constructors branch November 4, 2026 01:45
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NativeAOT] Support invoking string and array constructors on existing objects

4 participants