Skip to content

Narrow NativeAOT interop test exclusions - #133398

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix/nativeaot-interop-exclusions
Sep 9, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix/nativeaot-interop-exclusions

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Resolves dotnet/runtimelab#180.

Replace project-wide exclusions with inline guards for UnmanagedType.Error, System.Delegate fields, and unsupported StringBuilder callbacks, retaining unrelated marshalling coverage.

We should run all interop testing we can run. We may never implement the things triggering the disablement.

Replace project-wide exclusions with inline guards for UnmanagedType.Error, System.Delegate fields, and unsupported StringBuilder callbacks, retaining unrelated marshalling coverage.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3dea65e4-6bec-47a1-b938-b02f43d8a0bb
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 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.

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.

🟡 Changes recommended

The NativeAOT guards currently skip only call sites, but the unsupported interop paths remain rooted via always-reachable switch bodies, so NativeAOT compilation may still fail for the unsupported signatures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR narrows NativeAOT test exclusions in src/tests/Interop by removing project-wide <NativeAotIncompatible>true</NativeAotIncompatible> and replacing it with targeted runtime guards that skip known-unsupported marshalling scenarios while keeping the rest of the interop coverage enabled.

Changes:

  • Removed NativeAotIncompatible from several interop test projects so they can participate in NativeAOT test runs.
  • Added !Utilities.IsNativeAot / !TestLibrary.Utilities.IsNativeAot guards to skip specific failing struct IDs / callbacks (e.g., UnmanagedType.Error, delegate fields, certain LPSTR-out callbacks).
  • Annotated the skips with issue links to document why specific coverage is disabled under NativeAOT.
File summaries
File Description
src/tests/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/ReversePInvoke/ReversePInvokeTest.csproj Removes project-wide NativeAOT exclusion for this reverse-P/Invoke struct marshalling test.
src/tests/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/ReversePInvoke/ReversePInvokeTest_.cs Adds NativeAOT runtime guards around invoking S8/S9 test cases.
src/tests/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/DelegatePInvoke/DelegatePInvokeTest.csproj Removes project-wide NativeAOT exclusion for this delegate-P/Invoke test.
src/tests/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/DelegatePInvoke/DelegatePInvokeTest.cs Adds NativeAOT runtime guards around invoking S8/S9 test cases.
src/tests/Interop/StructMarshalling/PInvoke/MarshalStructAsLayoutSeq.csproj Removes project-wide NativeAOT exclusion for this P/Invoke struct marshalling test.
src/tests/Interop/StructMarshalling/PInvoke/MarshalStructAsLayoutSeq.cs Adds NativeAOT runtime guards for delegate-field scenario and S8/S9 test case invocation.
src/tests/Interop/BestFitMapping/BestFitMapping.csproj Removes project-wide NativeAOT exclusion for BestFitMapping interop coverage.
src/tests/Interop/BestFitMapping/BestFitMapping.cs Adds NativeAOT runtime guards to skip LPSTR-out callback paths under NativeAOT.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 3
  • Review effort level: Lite

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g mono crash was #133442

@MichalStrehovsky
MichalStrehovsky enabled auto-merge (squash) September 9, 2026 05:02
@MichalStrehovsky
MichalStrehovsky merged commit fd3d47d into dotnet:main Sep 9, 2026
95 of 97 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the fix/nativeaot-interop-exclusions branch September 9, 2026 05:02
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 9, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MarshalAs(UnmanagedType.Error)

3 participants