-
Notifications
You must be signed in to change notification settings - Fork 555
[dotnet] blitable network pinvokes #17071
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
[dotnet] blitable network pinvokes #17071
Conversation
This comment has been minimized.
This comment has been minimized.
src/ObjCRuntime/TransientString.cs
Outdated
| if (ptr != IntPtr.Zero) | ||
| free (ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call Marshal.FreeHGlobal here (and no need for the IntPtr.Zero check).
Unfortunately the documentation doesn't say what Marshal.FreeHGlobal will do on non-Windows platforms, but according to the source code, Marshal.FreeHGlobal will call NativeMemory.Free, and NativeMemory.Free is documented to call free: "This method is a thin wrapper over the C free API."
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes)
NET (empty diffs)
✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ Generator diffGenerator diff is empty Pipeline on Agent |
📚 [PR Build] Artifacts 📚Artifacts were not provided. Pipeline on Agent XAMBOT-1164.Monterey' |
💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻✅ All tests on macOS M1 - Mac Big Sur (11.5) passed. Pipeline on Agent |
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: simulator tests. 🎉 All 223 tests passed 🎉 Tests counts✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
fix all pinvokes in the Network package that use strings
Guiding principle for this PR: be unobtrusive
This meant making the changes as minor as possible
string, change thestringargs toIntPtrand inline thestring->TransientStringconversion.public int SomeFunc (string s) => SomePInvoke (s);), then I wrote a wrapper function for it that keeps the original signaturePtror_ptron the end, changed it to returnIntPtr, then wrote an adapter that uses calls is, allocates a new string and frees the original usingTransientString.ToStringAndFree