Skip to content

Clarify MarshalMode naming convention and return value coverage#52128

Merged
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
AaronRobinsonMSFT:fix/marshal-mode-docs
Mar 10, 2026
Merged

Clarify MarshalMode naming convention and return value coverage#52128
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
AaronRobinsonMSFT:fix/marshal-mode-docs

Conversation

@AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Mar 9, 2026

Summary

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.

Motivation

Addresses dotnet/runtime#124726 — a community user was confused about which MarshalMode to use for a custom marshaller that only handles return values from P/Invoke calls. The naming convention (ManagedToUnmanagedOut means 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.md

  • New Applies to column in the MarshalMode table showing the specific parameter/return contexts for each mode
  • Return values bolded in ManagedToUnmanagedOut and UnmanagedToManagedOut rows
  • New NOTE block after the table explaining:
    • The {CallDirection}{DataFlow} naming convention
    • Why ManagedToUnmanagedOut converts from unmanaged to managed (data flows back to the managed caller)

Companion PR: dotnet/dotnet-api-docs#12382

/cc @jkoritzinsky


Internal previews

📄 File 🔗 Preview link
docs/standard/native-interop/custom-marshalling-source-generation.md Source generation for custom marshalling

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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 MarshalMode table and highlights that Out modes cover return values.
  • Adds a NOTE block explaining the {CallDirection}{DataFlow} naming convention and how data flow relates to the marshaller direction.

…ion.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 9ee4b2d into dotnet:main Mar 10, 2026
9 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the fix/marshal-mode-docs branch March 10, 2026 22:11
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.

4 participants