Repository navigation
Keep buffers containing interior pointers as native pointers - #1840
Merged
Merged
Conversation
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Jevan Saks (jevansaks)
marked this pull request as ready for review
October 7, 2026 03:14
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Jevan Saks (jevansaks)
enabled auto-merge (squash)
October 7, 2026 16:50
Sergio Pedri (Sergio0694)
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Keep caller-owned buffers containing interior pointers as native pointers so callers can control their storage and pinning lifetime through output consumption.
in/ref/outbuffer projections for annotated parameters, including buffers sharing their capacity. Keep capacities explicit, including optional size pointers.Upgrade
Microsoft.Windows.SDK.Win32Metadatato71.0.30-previewto consumeContainsInteriorPointersAttributeand the buffer annotations from microsoft/win32metadata#2355.Examples
GetPrinterWat level 2 returns aPRINTER_INFO_2WwhosepPrinterNameand other pointers refer to data in the output buffer.GetTokenInformationwithTokenUserreturns aTOKEN_USERwhoseUser.Sidpoints into its output buffer. Both buffers are now annotated withContainsInteriorPointersAttribute.Representative overloads with default settings (
GetPrinterWis namedGetPrinter; namespaces, attributes, and bodies omitted):Before: the span overload pins only for the native call.
After: the buffer and capacity stay explicit;
SafeHandleand scalaroutprojections remain.A span backed by a managed array could move after the temporary pin ended, invalidating the returned printer-name or SID pointers. Callers must now supply storage that stays at the same address through both the call and consumption of those pointers.
Related: #1839.