Skip to content

Update StringBuilder documentation to be consistent about internal buffer copying#25003

Merged
adegeo merged 3 commits intomainfrom
jkoritzinsky/stringbuilder-copy
Jul 7, 2021
Merged

Update StringBuilder documentation to be consistent about internal buffer copying#25003
adegeo merged 3 commits intomainfrom
jkoritzinsky/stringbuilder-copy

Conversation

@jkoritzinsky
Copy link
Member

Summary

StringBuilder marshalling always copies the buffer to ensure that there is a null terminator at the end. It never reuses the internal buffer directly.

Fixes dotnet/runtime#47735

…ffer copying

StringBuilder marshalling always copies the buffer to ensure that there is a null terminator at the end. It never reuses the internal buffer directly.
@jkoritzinsky jkoritzinsky requested a review from a team as a code owner July 6, 2021 17:16
@dotnet-bot dotnet-bot added this to the July 2021 milestone Jul 6, 2021
Copy link
Member

@elinor-fung elinor-fung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also clarify the wording in the other doc the issue pointed at (https://docs.microsoft.com/dotnet/framework/interop/default-marshaling-for-strings#fixed-length-string-buffers: 'A StringBuilder can be dereferenced and modified by the callee') to indicate that it is a copy of the internal buffer?

@jkoritzinsky jkoritzinsky requested a review from elinor-fung July 6, 2021 21:22
@adegeo
Copy link
Contributor

adegeo commented Jul 7, 2021

@elinor-fung @jkoritzinsky Just to doublecheck, this content was written for .NET Framework, but I assume it applies to both .NET and .NET Framework?

@jkoritzinsky
Copy link
Member Author

Yes this applies to both. We have some other documentation in the shared folder that’s already been updated.

@adegeo adegeo merged commit 7723ba2 into main Jul 7, 2021
@adegeo adegeo deleted the jkoritzinsky/stringbuilder-copy branch July 7, 2021 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent/contradictory statements on StringBuilder marshaling in PInvoke

4 participants