Skip to content

[RGen] When a native string is created, released as part of the post invocation steps. #23029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

mandel-macaque
Copy link
Member

Instead than calling the GC.KeepAlive method we want to call CFString.Release native which keeps a ref to the native string and, more importantly, frees the memory of the string once we are done with it.

mandel-macaque and others added 2 commits June 11, 2025 16:46
…invocation steps.

Instead than calling the GC.KeepAlive method we want to call
CFString.Release native which keeps a ref to the native string and, more
importantly, frees the memory of the string once we are done with it.
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@mandel-macaque mandel-macaque requested a review from Copilot June 11, 2025 21:23
Copy link
Contributor

@Copilot 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 updates the string release mechanism by replacing GC.KeepAlive with CFString.ReleaseNative in the post invocation steps. Key changes include:

  • Updating tests to verify the use of CFString.ReleaseNative.
  • Modifying BindingSyntaxFactory.Trampoline.cs to call the new StringReleaseNative method.
  • Adding a new StringReleaseNative implementation and updating documentation in BindingSyntaxFactory.Runtime.cs.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryTrampolineTests.cs Updated test expectations to use CFString.ReleaseNative.
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Trampoline.cs Replaced GC.KeepAlive with StringReleaseNative in trampoline generation.
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Runtime.cs Added StringReleaseNative implementation and updated corresponding documentation.
Comments suppressed due to low confidence (1)

src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Runtime.cs:243

  • The documentation for NStringCreateNative incorrectly references 'NFString'. Update it to 'NString' for consistency with the method name.
/// Generates the expression to call the NFString.CreateNative method.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #8695ff1] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: ca0b7d642af7ad2740cd2ada565becd8bd78f0f7 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

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

Pipeline on Agent
Hash: ca0b7d642af7ad2740cd2ada565becd8bd78f0f7 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #8695ff1] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #8695ff1] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 115 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. 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: 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 9 tests passed. 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: 8695ff1cd85ddad625dad1eec8b0a5e318768204 [PR build]

@mandel-macaque mandel-macaque merged commit 0b313c8 into main Jun 12, 2025
36 of 40 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/release-native-string branch June 12, 2025 15:27
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.

5 participants