Skip to content

Reject WinRT metadata types in compiler type validation - #133397

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

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix/nativeaot-winrt-rejection

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

This is a trivial fix and lets us get rid of native AOT special casing (that I'm auditing for right now and might do that in the future too).

Match CoreCLR's TypeLoadException rejection of WindowsRuntime types and enable the NativeAOT WinRT regression test.

Resolves dotnet/runtimelab#182

Match CoreCLR's TypeLoadException rejection of WindowsRuntime types and enable the NativeAOT WinRT regression test.

Resolves dotnet/runtimelab#182

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.

🔵 Needs a closer look

It changes a shared compiler/type-validation rule with potentially broad impact across AOT/tooling scenarios, and I can’t validate downstream behavior or test outcomes here.

Pull request overview

This PR tightens the NativeAOT/compiler type-loadability validation to reject WinRT metadata types (tdWindowsRuntime) with a TypeLoadException, aligning the toolchain’s type rejection behavior with CoreCLR’s WinRT type-load rejection and un-skipping the corresponding Interop WinRT regression test.

Changes:

  • Removed the NativeAOT-specific [ActiveIssue] skip from the WinRT interop regression test so it runs under NativeAOT.
  • Added a WinRT metadata type rejection check (type.IsWindowsRuntime) to EnsureLoadableTypeUncached, throwing TypeLoadException via ThrowHelper.
File summaries
File Description
src/tests/Interop/WinRT/Program.cs Re-enables the WinRT regression test under NativeAOT by removing the conditional skip.
src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs Rejects WinRT metadata types during compiler type validation by throwing TypeLoadException.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • 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:16
@MichalStrehovsky
MichalStrehovsky merged commit 472811e into dotnet:main Sep 9, 2026
123 of 125 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the fix/nativeaot-winrt-rejection branch September 9, 2026 05:16
@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.

Fail predictably and with better error message for WinRT

3 participants