Skip to content

Conversation

@rolfbjarne
Copy link
Member

Otherwise the trimmer might end up trimming away the exported method, and if that happens, the event will never be raised.

Fixes #24262.
Backport of #24270.

…orted method for generated events. Fixes #24262.

Otherwise the trimmer might end up trimming away the exported method, and if
that happens, the event will never be raised.

Fixes #24262.
Copy link
Contributor

Copilot AI left a comment

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 fixes a trimming issue where the trimmer could remove exported methods for generated events, preventing events from being raised. The fix adds a [DynamicDependency] attribute to event backing fields that references the corresponding delegate method, ensuring the trimmer preserves these methods when events are subscribed to.

Key Changes:

  • Added [DynamicDependency(nameof(...))] attribute to generated event backing fields in the binding generator
  • Added comprehensive tests covering both custom types and SDK types (NSCache)
  • Updated expected NativeAOT app sizes to reflect the additional preserved code

Reviewed Changes

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

Show a summary per file
File Description
src/bgen/Generator.cs Added [DynamicDependency] attribute to event field declarations to prevent trimmer from removing delegate methods
tests/bindings-test/ApiDefinition.cs Added Hitchhiker and HitchhikerDelegate binding definitions for testing custom type events
tests/test-libraries/libtest.h Added Objective-C interface declarations for Hitchhiker test class
tests/test-libraries/libtest.m Added Objective-C implementation for Hitchhiker test class
tests/monotouch-test/ObjCRuntime/RegistrarTest.cs Added two test methods validating event handling for custom and SDK types
tests/dotnet/UnitTests/expected/iOS-NativeAOT-size.txt Updated expected app bundle sizes reflecting preserved code (~20KB increase)

Assert.That (earthDestroyed, Is.True, "Event raised");
}


Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Extra blank line. Consider removing this extra line to maintain consistency with the spacing between other test methods in this file.

Suggested change

Copilot uses AI. Check for mistakes.
This reverts commit da4d4c7.
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #ca21234] Build passed (Build packages) ✅

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #ca21234] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
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: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #ca21234] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #ca21234] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #ca21234] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #ca21234] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #ca21234] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #ca21234] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #ca21234] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 120 tests passed 🎉

Tests counts

✅ 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. [attempt 2] 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 6 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 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

Pipeline on Agent
Hash: ca21234af1e28ab906647c472f3a3658d6d504b6 [PR build]

@rolfbjarne rolfbjarne merged commit 8899c27 into release/10.0.1xx Nov 19, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants