-
Notifications
You must be signed in to change notification settings - Fork 511
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
[src] Make BlockLiteral disposable and update usage accordingly. #17597
Conversation
This also means to modify the cleanup logic so that it's safe to call Dispose more than once.
…tion delegate. This allows us to simplify a good chunk of code.
Update all block creation to use the new block API, where blocks are disposable. This makes the code pattern a lot simpler. I've changed all the P/Invokes to use an unsafe 'BlockLiteral*' pointer, because 'using' variables can't be passed as ref arguments, so the choice was either to make the parameter type 'IntPtr' and cast away the pointer: using var block = new BlockLiteral (); PInvoke ((IntPtr) &block); or make the parameter an unsafe 'BlockLiteral*' pointer: unsafe { using var block = new BlockLiteral (); PInvoke (&block); } The upcoming support for function pointers don't have this choice: function pointers are always unsafe, so I chose to go the unsafe route here as well, since it makes the code simpler once support for function pointers has been implemented.
|
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.
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ Generator diffGenerator diff is empty Pipeline on Agent |
❌ [PR Build] Tests on macOS M1 - Mac Ventura (13.0) failed ❌Failed tests are:
Pipeline on Agent |
💻 [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❌ Tests failed on VSTS: simulator tests 0 tests crashed, 2 tests failed, 223 tests passed. Failures❌ xammac tests
Html Report (VSDrops) Download Successes✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Test failure is unrelated (https://github.com/xamarin/maccore/issues/2630). |
Make BlockLiteral disposable.
This also means to modify the cleanup logic so that it's safe to call
Dispose more than once.
Create a helper class to create a block for a simple Action delegate.
This allows us to simplify a good chunk of code.
Update all block creation to use the new block API, where blocks are
disposable. This makes the code pattern a lot simpler.
I've changed all the P/Invokes to use an unsafe 'BlockLiteral*' pointer,
because 'using' variables can't be passed as ref arguments, so the choice
was either to make the parameter type 'IntPtr' and cast away the pointer:
or make the parameter an unsafe 'BlockLiteral*' pointer:
The upcoming support for function pointers don't have this choice:
function pointers are always unsafe, so I chose to go the unsafe route
here as well, since it makes the code simpler once support for function
pointers has been implemented.
Contributes towards #15783.
This PR might be easier to review commit-by-commit.