Clarify MarshalMode naming convention and return value coverage#52128
Merged
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom Mar 10, 2026
Merged
Clarify MarshalMode naming convention and return value coverage#52128AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
Conversation
Add an 'Applies to' column to the MarshalMode table and a NOTE block
explaining the {CallDirection}{DataFlow} naming convention. Explicitly
call out that Out modes cover return values, not just out parameters.
Addresses dotnet/runtime#124726
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR clarifies how to interpret MarshalMode names in the custom marshalling source-generation docs, specifically making it explicit that Out modes apply to return values (not only out parameters) and explaining the {CallDirection}{DataFlow} naming convention.
Changes:
- Adds an Applies to column to the
MarshalModetable and highlights thatOutmodes cover return values. - Adds a NOTE block explaining the
{CallDirection}{DataFlow}naming convention and how data flow relates to the marshaller direction.
docs/standard/native-interop/custom-marshalling-source-generation.md
Outdated
Show resolved
Hide resolved
jkoritzinsky
approved these changes
Mar 9, 2026
…ion.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
gewarren
approved these changes
Mar 10, 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
Add an
Applies tocolumn to theMarshalModetable and a NOTE block explaining the{CallDirection}{DataFlow}naming convention. Explicitly call out thatOutmodes cover return values, not justoutparameters.Motivation
Addresses dotnet/runtime#124726 — a community user was confused about which
MarshalModeto use for a custom marshaller that only handles return values from P/Invoke calls. The naming convention (ManagedToUnmanagedOutmeans data flowing out of a managed-to-unmanaged call) is non-obvious and was not explained anywhere in the docs.Changes to
custom-marshalling-source-generation.mdApplies tocolumn in theMarshalModetable showing the specific parameter/return contexts for each modeManagedToUnmanagedOutandUnmanagedToManagedOutrows{CallDirection}{DataFlow}naming conventionManagedToUnmanagedOutconverts from unmanaged to managed (data flows back to the managed caller)Companion PR: dotnet/dotnet-api-docs#12382
/cc @jkoritzinsky
Internal previews