Skip to content

Fix managed IID_PPV_ARGS overloads for native COM out pointers#1733

Merged
jevansaks merged 1 commit into
microsoft:mainfrom
littletoxic:fix-issue-1608-iid-ppv
Jun 16, 2026
Merged

Fix managed IID_PPV_ARGS overloads for native COM out pointers#1733
jevansaks merged 1 commit into
microsoft:mainfrom
littletoxic:fix-issue-1608-iid-ppv

Conversation

@littletoxic

Copy link
Copy Markdown
Contributor

Summary

  • Treat IID_PPV_ARGS overloads as managed when AllowMarshaling is enabled, even when the extern ppv parameter remains native void**.
  • Convert native COM out pointers to managed T for both source-generated and built-in COM paths.
  • Add regression coverage for ID3D12Device.CreateCommittedResource, including build-task generation.

Fixes #1608

Notes

CreateCommittedResource marks ppvResource as optional, and native callers may pass nullptr for capability testing. This PR intentionally does not add a generic friendly overload that omits ppvResource; it only fixes the existing IID_PPV_ARGS generic overload so AllowMarshaling=true produces out T where T : class. Please let me know if you would prefer adding an omitted-output friendly overload as well.

This PR was created with assistance from Codex.

Validation

Local targeted validation was run with NBGV_GitEngine=Disabled. I did not run the full local test suite because the PR CI covers the full Windows/Linux and heavy-test matrix.

  • dotnet build src\CsWin32Generator\CsWin32Generator.csproj --no-restore
    • Passed; observed an existing PrimitiveTypeHandleInfo.cs CS9336 warning under local SDK 10.0.301.
  • dotnet test test\Microsoft.Windows.CsWin32.Tests\Microsoft.Windows.CsWin32.Tests.csproj --no-restore --filter "FullyQualifiedName~ComOutPtrGenericOverload"
    • Passed: 11 tests.
  • dotnet test test\GenerationSandbox.BuildTask.Tests\GenerationSandbox.BuildTask.Tests.csproj --no-restore --filter "FullyQualifiedName~ID3D12Device_CreateCommittedResource_GenericOverloadsCompile"
    • Passed for net9.0-windows10.0.22621.0 and net10.0-windows10.0.22621.0.

@littletoxic

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@jevansaks

Copy link
Copy Markdown
Member

Thanks @littletoxic for the contribution! I'll take a look.

@jevansaks jevansaks merged commit 50af50f into microsoft:main Jun 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Friendly overload (out object) missing for methods with [Optional] COM output parameters

2 participants