Repository navigation
[registrar] Detect open generic proxy types correctly - #26810
Conversation
Cecil's TypeDefinition.ContainsGenericParameter is false for open generic type definitions, so the trimmable registrar still emitted invalid newobj instructions for generic NSObject proxies. NativeAOT then reported that NSLayoutAnchor<T>_Proxy.CreateObject would always throw.\n\nUse HasGenericParameters for NSObject, INativeObject, and protocol-wrapper proxy generation, and add focused assembly-preparer coverage that verifies generic CreateObject proxies throw instead of constructing an open generic type.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: ece6a6bd-3e29-4559-b8f3-4465690e25a4
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The generic INativeObject and protocol-wrapper proxy paths lack focused regression coverage.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Corrects generic proxy detection in the trimmable registrar to avoid invalid open-generic construction.
Changes:
- Uses
HasGenericParametersacross three proxy-generation paths. - Adds regression coverage for generic
NSObjectproxies.
| File | Description |
|---|---|
tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs |
Corrects open-generic proxy detection. |
tests/assembly-preparer/ManagedRegistrarStepTests.cs |
Tests generic NSObject proxy IL generation. |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #90538c6] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 221 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
…tly (#26834) Cecil's `TypeDefinition.ContainsGenericParameter` is false for open generic type definitions, so the trimmable registrar still emitted invalid `newobj` instructions for generic `NSObject` proxies. NativeAOT then reported that `NSLayoutAnchor<T>_Proxy.CreateObject` would always throw: ``` UIKit.NSLayoutAnchor<T>_Proxy.CreateObject(native int) will always throw ``` Use `HasGenericParameters` for `NSObject`, `INativeObject`, and protocol-wrapper proxy generation, and add focused assembly-preparer coverage that verifies generic `CreateObject` proxies throw instead of constructing an open generic type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ece6a6bd-3e29-4559-b8f3-4465690e25a4 Backport of #26810. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Alex Soto <alex@soto.dev> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dalexsoto <204671+dalexsoto@users.noreply.github.com> Copilot-Session: 02e333bf-a325-4045-a5b4-75917e002856

Cecil's
TypeDefinition.ContainsGenericParameteris false for open generic type definitions, so the trimmable registrar still emitted invalidnewobjinstructions for genericNSObjectproxies. NativeAOT then reported thatNSLayoutAnchor<T>_Proxy.CreateObjectwould always throw:Use
HasGenericParametersforNSObject,INativeObject, and protocol-wrapper proxy generation, and add focused assembly-preparer coverage that verifies genericCreateObjectproxies throw instead of constructing an open generic type.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Copilot-Session: ece6a6bd-3e29-4559-b8f3-4465690e25a4