Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
@stephentoub questions:
[StructLayout(Sequential)]on any class where we care about the field layout. Otherwise we're just relying on auto layout coincidentally getting the fields in the right order.SafeHandle.Mono.csandSafeHandle.CoreCLR.csthat just contain the instance field definitions?#if DEBUG && CORECLRaccomplishes the same thing but feels more fragile.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.
I'd previously done that, and I believe the issues I hit were to do with alignment, though it's also possible I just messed something up or neglected to edit something I needed to edit.
This is irrespective of this change or this field, right? You're saying mono is expecting that handle is first and it may not be.
I don't love the duplication there; that feels more fragile to me, actually. If this field is problematic, we can just remove it and I can put it back in the future should someone want to do another push like I did to drive down SafeHandle finalization debt.
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.
Yea, it's not required for this PR (all the other fields are non-reference so auto layout will get things right). Just might as well do some future-proofing
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.
Overall I'm fine with the PR as is. It would be nice to get the layout attribute in here, but we could also do a separate PR for that. If splitting the file feels more fragile to you @stephentoub , I'm ok with the PR as is.
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.
@lambdageek, mono actually already has StructLayout applied:
runtime/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.Mono.cs
Lines 6 to 8 in 5e3dd8d