Generate generic <T> overloads for IID_PPV_ARGS pattern on COM methods - #1720
Merged
Jevan Saks (jevansaks) merged 1 commit intoJun 11, 2026
Merged
Conversation
Jevan Saks (jevansaks)
force-pushed
the
user/jevansa/iid-ppv-args-generic-overloads
branch
5 times, most recently
from
June 10, 2026 23:51
d327d2b to
422814f
Compare
Auto-detect COM methods with the IID_PPV_ARGS pattern (a Guid* parameter immediately followed by a void** [ComOutPtr] parameter) and generate generic <T> overloads where the GUID is derived from typeof(T).GUID and the output pointer is typed as T. For marshaling mode: out T ppv where T : class For non-marshaling mode: out T* ppv where T : unmanaged Added friendlyOverloads.comOutPtrGenericOverloads option (default true) to nativemethods.json for opt-out. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jevan Saks (jevansaks)
force-pushed
the
user/jevansa/iid-ppv-args-generic-overloads
branch
from
June 11, 2026 00:11
422814f to
52643a7
Compare
Jevan Saks (jevansaks)
marked this pull request as ready for review
June 11, 2026 01:19
Sergio Pedri (Sergio0694)
approved these changes
Jun 11, 2026
Jevan Saks (jevansaks)
deleted the
user/jevansa/iid-ppv-args-generic-overloads
branch
June 11, 2026 17:18
This was referenced Sep 3, 2026
This was referenced Sep 6, 2026
Merged
Open
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
Auto-detect COM methods with the IID_PPV_ARGS pattern (a
Guid*parameter immediately followed by avoid** [ComOutPtr]parameter) and generate generic<T>overloads where the GUID is derived fromtypeof(T).GUIDand the output pointer is typed asT.Closes #374
Fixes #1604
Example
Before — callers must construct and pass the IID manually:
After — the generic overload handles it:
Generated overload shapes
AllowMarshaling=true)BindToHandler<T>(..., out T ppv)where T : classAllowMarshaling=false)BindToHandler<T>(..., out T* ppv)where T : unmanagedChanges
GeneratorOptions.cs— AddedFriendlyOverloadOptions.ComOutPtrGenericOverloads(defaulttrue)settings.schema.json— AddedfriendlyOverloads.comOutPtrGenericOverloadsfor opt-outGenerator.cs/Generator.Invariants.cs— Extract IUnknownHelperMethods template method names to avoid duplicatingQueryInterface<T>Generator.FriendlyOverloads.cs— Pattern detection (DeclareComOutPtrGenericOverloads) and code generation (BuildComOutPtrGenericOverload)COMTests.cs— 5 new tests for marshaling/non-marshaling, opt-out, template precedence, and IntPtr modeDesign decisions
void**(not typed pointers likeID2D1Effect**) — typed outputs already have their specific typeCoCreateInstance<T>template retained for co-creatable classCreateInstance<T>integrationUseIntPtrForComOutPointersis active (ppv isIntPtr, not castable)