You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enhancementThe issue or pull request is an enhancementiOSIssues affecting iOSmacOSIssues affecting macOSrequest-for-commentsThe issue is a suggested idea seeking feedback
Make BlockLiteral implement IDisposable (and call CleanupBlock in Dispose).
Add a BlockLiteral constructor that takes the corresponding delegates.
Add support to the linker/optimizer for the new BlockLiteral constructor.
Change P/Invokes to take ref BlockLiteral instead of void * or IntPtr (this only works if the block isn't nullable).
Advantages
Much smaller & simpler C# code.
We won't leak the block if the P/Invoke (or any code after setting up the block) throws an exception.
Disadvantages
I think we'd end up creating more compiled (both IL and native), because of the additional exception handling by the using statement. This would need to be confirmed by testing though.
Reacted by Rolf Bjarne Kvinge, Sebastien Pouliot, Marius Ungureanu and Alex Soto
I think it's easy to measure the potential disadvantage (if any) before implementing the generator/linker changes.
Another advantage is that we sometimes needs to use the blocks in non-generated (manual) code. Hiding most details will reduce potential bugs and ease maintainability (right now a required change would need a lot of sites to fix).
Testing-wise we should ensure that, even if easier, manual implementation are optimizable (if decorated as such). In fact we might want to do that in parallel (or without the RFC) since this is an existing situation (even if they all work today it's hard to guarantee they will remain that way). #4547 (review)
we should ensure that manual implementation are optimizable
All block creations in our platform assemblies must be optimizable, otherwise we can't safely remove the dynamic registrar.
This is enforced by tests.
The only way to ensure that any optimization is working correctly, is to execute the optimized code. Which is one of the reasons we need to write tests (monotouch-tests) for all manually bound code 😄 (we execute monotouch-test both in optimized and non-optimized mode).
enhancementThe issue or pull request is an enhancementiOSIssues affecting iOSmacOSIssues affecting macOSrequest-for-commentsThe issue is a suggested idea seeking feedback
Activity
spouliot commentedon Aug 1, 2018
I think it's easy to measure the potential disadvantage (if any) before implementing the generator/linker changes.
Another advantage is that we sometimes needs to use the blocks in non-generated (manual) code. Hiding most details will reduce potential bugs and ease maintainability (right now a required change would need a lot of sites to fix).
spouliot commentedon Aug 1, 2018
Testing-wise we should ensure that, even if easier, manual implementation are optimizable (if decorated as such). In fact we might want to do that in parallel (or without the RFC) since this is an existing situation (even if they all work today it's hard to guarantee they will remain that way).
#4547 (review)
rolfbjarne commentedon Aug 2, 2018
All block creations in our platform assemblies must be optimizable, otherwise we can't safely remove the dynamic registrar.
This is enforced by tests.
The only way to ensure that any optimization is working correctly, is to execute the optimized code. Which is one of the reasons we need to write tests (monotouch-tests) for all manually bound code 😄 (we execute monotouch-test both in optimized and non-optimized mode).
rolfbjarne commentedon Sep 23, 2022
Duplicate of #15783.