Skip to content

[src] Generate accessors for native binding constants - #26290

Merged
rolfbjarne merged 10 commits into
mainfrom
dev/rolf/generate-dlfcn-constants-src-only
Jul 29, 2026
Merged

[src] Generate accessors for native binding constants#26290
rolfbjarne merged 10 commits into
mainfrom
dev/rolf/generate-dlfcn-constants-src-only

Conversation

@rolfbjarne

@rolfbjarne rolfbjarne commented Jul 24, 2026

Copy link
Copy Markdown
Member

Move eligible AddressBook, CoreFoundation, and OpenGLES constants from handwritten Dlfcn.Get*Constant initialization into bgen [Field] definitions.

What changed

  • Generate native constant accessors for AddressBook, CoreFoundation, and OpenGLES bindings.
  • Remove the corresponding strict static constructors, AddressBook's shared InitConstants coordinator, handwritten loaders, and the now-unused OpenGLES library handle.
  • Preserve the existing public properties, readonly fields, platform availability, obsoletion metadata, and nullable signatures.
  • Keep the 22 shipped readonly fields and their internal underscored bindings under !XAMCORE_5_0, while exposing public generated properties under XAMCORE_5_0.
  • Teach bgen to honor [NullAllowed] on [Field] properties, with focused regression coverage.
  • Remove resolved CoreFoundation xtro exclusions and update the iOS and Mac Catalyst NativeAOT app-size baselines to reflect the smaller binaries.

Validation

  • Managed binding generation, build, and installation succeeded for all four platforms.
  • API compatibility found no breaking changes for iOS, tvOS, Mac Catalyst, or macOS; the generated API diff retains the existing nullable signatures.
  • The focused bgen field-nullability test passed.
  • Cecil duplicate-attribute checks passed on all four platforms.

This is a focused follow-up for #16672.

🤖 Pull request created by Copilot

Move eligible AddressBook, CoreFoundation, and OpenGLES constants into binding definitions while preserving existing public fields and properties.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bf11d7ec-2d59-4fad-876b-35900de01718
Keep the existing Contacts and Metal migration warnings on public partial constant-holder types.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bf11d7ec-2d59-4fad-876b-35900de01718
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

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.

Pull request overview

This PR migrates a set of OpenGLES, CoreFoundation, and AddressBook “native binding constants” from handwritten Dlfcn.Get* initialization patterns to bgen-generated [Field] accessors, with the intent of removing explicit static constructors and keeping the existing public surface shape.

Changes:

  • Replaced manual constant initialization (static constructors / init coordinators) with bgen [Field]-generated accessors for OpenGLES (EAGL*), CoreFoundation (CFErrorDomain/CFExceptionDataKey/CFPreferences), and AddressBook constants.
  • Removed the AddressBook InitConstants coordinator and related per-type initialization code.
  • Updated affected constant-holder types to partial and routed their public fields/properties through internal generated accessors.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/OpenGLES/EAGLConsts.cs Switches EAGL NSString constants to generated accessors; removes explicit static constructors.
src/opengles.cs Adds [Field] definitions for EAGL constant symbols used by EAGLConsts.cs.
src/ObjCRuntime/Dlfcn.cs Removes the handwritten Libraries.OpenGLES handle entry (now expected to be handled elsewhere).
src/CoreFoundation/CFPreferences.cs Replaces static ctor-based constant initialization with generated [Field] accessor.
src/CoreFoundation/CFException.cs Routes CF error-domain / error-key constants through generated accessors and removes static ctors.
src/corefoundation.cs Adds bgen [Field] definitions backing CF constant accessors.
src/AddressBook/ABSource.cs Removes manual property-id initialization and relies on generated constants.
src/AddressBook/ABPerson.cs Removes manual constant initialization and InitConstants.Init () usage; prepares for generated constants.
src/AddressBook/ABGroup.cs Removes manual constant initialization and InitConstants.Init () usage.
src/AddressBook/ABAddressBook.cs Removes InitConstants and binds ErrorDomain via generated constant accessor.
src/addressbook.cs Adds bgen [Field] definitions for AddressBook int/NSString/NSNumber constants.

Comment thread src/addressbook.cs
@rolfbjarne
rolfbjarne marked this pull request as ready for review July 27, 2026 18:04
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner July 27, 2026 18:04
Keep legacy internal bindings and public readonly fields before XAMCORE 5, while exposing generated public properties in XAMCORE 5.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bf11d7ec-2d59-4fad-876b-35900de01718
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

⚠️ AppSizeTest expected files changed ⚠️

The AppSizeTest detected changes in the expected app size files.

To update the expected files, add a comment with the following command:

/apply-gist https://gist.github.com/vs-mobiletools-engineering-service2/b59b422f657ed9943e736f6ff9a9faee
Updated files
  • iOS-NativeAOT-TrimmableStatic-size.txt
  • MacCatalyst-NativeAOT-TrimmableStatic-size.txt

Pipeline on Agent
Hash: 52aa46bc22b6c6e3dca002663263d27156e7640e [PR build]

Comment thread src/CoreFoundation/CFException.cs Outdated
rolfbjarne and others added 5 commits July 28, 2026 10:49
Teach bgen to honor NullAllowed on Field properties and retain the nullable signatures of migrated AddressBook constants and future XAMCORE 5 properties.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bf11d7ec-2d59-4fad-876b-35900de01718
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: ef60e0d4c282a52b6aaa9f29f00590bd24b637e6 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #ef60e0d] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 203 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: ef60e0d4c282a52b6aaa9f29f00590bd24b637e6 [PR build]

@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Jul 28, 2026
@rolfbjarne
rolfbjarne enabled auto-merge (squash) July 28, 2026 17:22
@rolfbjarne
rolfbjarne merged commit 85907cd into main Jul 29, 2026
56 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/generate-dlfcn-constants-src-only branch July 29, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants