Add support for custom overload names to CsWinMD#2275
Open
talagrand wants to merge 2 commits into
Open
Conversation
Member
|
Thanks for this change and the tests, I have kicked off the CI. |
Author
|
There is a remaining issue with CsWinMD despite the tests passing. I need to push an addition to this change over the next couple days. |
Member
|
Ported to 3.0 in #2454. @manodasanW should we just abandon this one or do we still want it? |
Sergio0694
added a commit
that referenced
this pull request
Jul 24, 2026
* Honor author-specified [Overload] names in the WinMD generator Port custom overload name support from PR #2275 (CsWinRT 2.x) to the CsWinRT 3.0 WinMD generator (cswinrtwinmdgen). When an authored method carries [Windows.Foundation.Metadata.Overload("Name")], emit that name in the generated .winmd instead of an auto-generated sequential one. windows-rs consumers require explicit overload names because Rust has no method overloading. - Record author-specified overload names while emitting interface methods and honor them in AddOverloadAttributesForType; stop copying the [Overload] attribute verbatim so it is never duplicated. - Select the default overload (which keeps the original name) from the [DefaultOverload] attribute rather than metadata order, so an author-specified name is not dropped when the default is not declared first. - Auto-generated names skip any name already used by another method or an author-specified overload, avoiding collisions. - Emit [Overload] only on interfaces (authored and synthesized), matching the Windows Runtime metadata convention; runtime classes expose their ABI through interfaces (consistent with CsWinRT 2.x). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Port custom overload name tests from PR #2275 Add the ICustomOverloadNames interface and CustomOverloadNamesClass authoring types, and the CustomOverloadNames consumption test. The test validates that author-specified [Overload] names (LookupByIndex, LookupByFlag, TransformNumber) appear in the generated projection's ABI vtables, on both an authored interface and a class's synthesized interface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add overload-name coverage for auto-generation, collisions, and default selection Extend the overload-name tests to cover behaviors beyond the original PR: - Verify the auto-generated ABI name (Transform2) coexists with an author- specified one (TransformNumber) in the same overload group. - OverloadCollisionClass: an author-specified overload name matching the auto pattern ("M2") forces the auto-generated name of the remaining overload to skip it ("M3"). - DefaultOverloadNotFirstClass / IDefaultOverloadNotFirst: [DefaultOverload] on a non-first overload keeps the original ABI name, while the author-specified name ("GetByIndex") on the first overload is still honored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
This brings in support for OverloadAttribute to CsWinMD, so that the generated WinMD file carries that metadata.
Rust does not have support for overloaded methods, so windows-rs based consumers require this attribute to be set for API ergonomics.