Repository navigation
[bgen] Support Wrap on protocol members. Fixes #9696 - #27180
rolfbjarne wants to merge 2 commits into
Conversation
Generate default interface implementations for wrapped protocol methods and properties, including accessor-level conversions. Keep these managed conveniences separate from exported protocol members so they do not add Objective-C selectors or required/optional protocol metadata. Wrapped methods on model classes now execute their forwarding bodies instead of throwing. Expose the existing typed delegates, dictionaries, enum arrays, struct conversions and compatibility aliases through protocol interfaces. Move the handwritten CISystemToneMap dynamic-range properties into the binding definition, preserving the concrete class API through filter generation. Add cross-platform regression coverage for wrappers, inheritance, model classes, static members and the ported APIs. Document the newly visible members and remove the documentation failures resolved by those comments. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c4e0d085-6d69-4fcb-8232-75056e83a58f
Replace the null-forgiving conversion in the newly exposed protocol overload with an explicit ArgumentOutOfRangeException when the enum has no native constant. This avoids hiding a nullable conversion and gives callers an actionable error before invoking the underlying binding. Document the exception on the shared binding definition. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c4e0d085-6d69-4fcb-8232-75056e83a58f
There was a problem hiding this comment.
🟡 Changes recommended
Cross-assembly protocol inheritance can fail binding generation with BI1018 because non-exported convenience properties are imported as contracts, and regression tests leave generated setters unchecked.
2 open issues
What changed in this PR
Adds [Wrap] support to bgen protocol interfaces, addressing #9696 by exposing managed convenience members without adding Objective-C protocol metadata.
Changes:
- Generates default interface implementations for wrapped methods, properties, and accessors, and forwarding bodies for model methods.
- Moves
CISystemToneMap.PreferredDynamicRangeinto the binding definition while preserving its concrete-class API. - Adds cross-platform regression coverage, documents exposed APIs, and removes resolved documentation failures.
| File | Description |
|---|---|
| tests/cecil-tests/Documentation.KnownFailures.txt | Removes entries for newly documented APIs. |
| tests/bgen/tests/protocol-wrap.cs | Adds protocol wrapper binding fixtures. |
| tests/bgen/ProtocolWrapTests.cs | Checks generated wrappers and platform APIs. |
| src/videotoolbox.cs | Documents pixel format and buffer wrappers. |
| src/uikit.cs | Documents the typed preview delegate. |
| src/photosui.cs | Documents the category overload and rejects invalid constants. |
| src/mediaextension.cs | Documents sample information wrappers. |
| src/frameworks.sources | Removes handwritten tone-map source entries. |
| src/CoreImage/ICISystemToneMapProtocol.cs | Removes the handwritten interface property. |
| src/CoreImage/CISystemToneMap.cs | Removes the handwritten class property. |
| src/coreimage.cs | Defines the tone-map property using accessor wrappers. |
| src/browserenginekit.cs | Documents the asynchronous input delegate. |
| src/bgen/Generator.cs | Emits managed protocol wrappers and model forwarding bodies. |
| src/bgen/Filters.cs | Generates wrapped properties on concrete filters. |
| src/avfoundation.cs | Documents the download callback alias. |
| src/authenticationservices.cs | Documents algorithm-array wrappers. |
| src/appkit.cs | Documents the item-count compatibility alias. |
| docs/website/binding_types_reference_guide.md | Explains protocol wrapper behavior. |
Review effort: Balanced
| foreach (var pi in SelectProtocolProperties (type, wrapped: true)) { | ||
| GenerateProperty (type, pi, null, false, is_protocol_member: true); |
| Assert.That (type, Is.Not.Null, member.Type); | ||
| var property = type.Properties.FirstOrDefault (v => v.Name == member.Member); | ||
| if (property is not null) { | ||
| Assert.That (property.GetMethod?.HasBody, Is.True, property.FullName); |
✅ 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 #de9507a] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 5 tests failed, 212 tests passed. Failures❌ dotnettests tests (macOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ generator tests1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests1 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Sonoma (14) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
|


Generate default interface implementations for wrapped protocol methods and properties, including accessor-level conversions. Keep these managed conveniences separate from exported protocol members so they do not add Objective-C selectors or required/optional protocol metadata. Wrapped methods on model classes now execute their forwarding bodies instead of throwing.
Expose the existing typed delegates, dictionaries, enum arrays, struct conversions and compatibility aliases through protocol interfaces. Move the handwritten CISystemToneMap dynamic-range properties into the binding definition, preserving the concrete class API through filter generation.
Add cross-platform regression coverage for wrappers, inheritance, model classes, static members and the ported APIs. Document the newly visible members and remove the documentation failures resolved by those comments.
Fixes #9696
🤖 Pull request created by Copilot