-
Notifications
You must be signed in to change notification settings - Fork 519
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
[Bgen] Improve the generated code for SmarEnum BindAs calls. #22323
base: main
Are you sure you want to change the base?
Conversation
Because we now have a GetValue method that takes a NativeHandle, we can simplify the code generated when we are dealing with a smart enum in a BindAs decorated property/method. The old generated code is: ```csharp ret = global::CoreAnimation.CACornerCurveExtensions.GetValue (Runtime.GetNSObject<NSString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("cornerCurve")), false)!); ``` While the new one is: ```csharp ret = global::NaturalLanguage.NLLanguageExtensions.GetValue (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.SuperHandle, Selector.GetHandle ("language"))); ``` The code is simpler, but there is also a small memory imrpovement. In the old version of the binding, we were not callin the Dispose method in the NSString. On the other hand, the new code uses the GetValue method that is disposing the NSString as soon as it leaves the method and therefore it does not need the GC to take care of it.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #ceede5d] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #ceede5d] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #ceede5d] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #ceede5d] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #ceede5d] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
✅ API diff for current PR / commit.NET ( No breaking changes )❗ API diff vs stable (Breaking changes).NET ( ❗ Breaking changes ❗ )ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
💻 [CI Build #ceede5d] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
❌ [CI Build #ceede5d] Windows Integration Tests failed ❌❌ Failed ❌ Pipeline on Agent |
❌ [CI Build #65b637e] Windows Integration Tests failed ❌❌ Failed ❌ Pipeline on Agent |
❌ [CI Build #ceede5d] Tests on macOS arm64 - Mac Sequoia (15) failed ❌Failed tests are:
Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build #ceede5d] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 1 tests failed, 111 tests passed. Failures❌ generator tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Because we now have a GetValue method that takes a NativeHandle, we can simplify the code generated when we are dealing with a smart enum in a BindAs decorated property/method.
The old generated code is:
While the new one is:
The code is simpler, but there is also a small memory imrpovement. In the old version of the binding, we were not callin the Dispose method in the NSString. On the other hand, the new code uses the GetValue method that is disposing the NSString as soon as it leaves the method and therefore it does not need the GC to take care of it.
PS: There is no need to change the code that creates the wrapper because we are using method overloading.