Repository navigation
[ObjCRuntime] Reject non-native generic arguments in exported signatures. Fixes #15709 - #27291
rolfbjarne wants to merge 3 commits into
Conversation
…res. Validate generic native-object signatures in the shared registrar so the dynamic registrar reports error 4167 for enum and other non-native generic arguments, including nested wrappers. Cover rejected return and parameter signatures, supported native-object arguments, and the non-generic subclass workaround. Update the diagnostic documentation to describe the restriction. Fixes #15709. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Limit the generic argument check to NSObject subclasses, matching the static registrar. Keep other INativeObject wrappers supported and add a regression case for a generic NativeObject wrapper with a string argument. Clarify the scope of error 4167 in its documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Avoid resolving CoreFoundation to the sibling test namespace. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The shared registrar change lacks coverage for the Cecil-based static registration path, since the regression test exercises only dynamic Runtime.ConnectMethod registration.
1 open issue
What changed in this PR
This PR addresses #15709 by tightening exported-signature validation so the dynamic registrar rejects unsupported generic arguments with error 4167.
Changes:
- Reject non-native generic arguments recursively for
NSObjectwrappers. - Add dynamic-registration tests for invalid signatures and supported wrapper forms.
- Update error 4167 documentation with the restriction and a workaround.
| File | Description |
|---|---|
| tests/monotouch-test/ObjCRuntime/RegistrarTest.cs | Adds regression coverage for rejected and supported generic signatures. |
| src/ObjCRuntime/Registrar.cs | Requires generic arguments of NSObject wrappers to implement INativeObject. |
| docs/website/mtouch-errors.md | Corrects error 4167 guidance and recommends non-generic subclasses. |
Review effort: Balanced
| if (IsNSObject (type) && !IsINativeObject (argument)) | ||
| throw CreateException (4167, member, Errors.MT4167, member?.FullName, GetTypeFullName (type), GetTypeFullName (argument)); |
✅ 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 |
🔥 [CI Build #dd2e1ad] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 1 tests failed, 216 tests passed. Failures❌ monotouch tests (iOS)1 tests failed, 19 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ 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 |

Make the dynamic registrar reject exported signatures such as
EnumWrapper<MyEnum>with error 4167 instead of accepting them accidentally. Check generic arguments recursively, while keeping native-object arguments, non-generic derived wrappers, and non-NSObject native wrappers supported.Add regression coverage and update the error documentation. The full NSObject generics guide is being ported in dotnet/docs-mobile#156.
Fixes #15709
🤖 Pull request created by Copilot