Skip to content

[Mgmt] Fix duplicate WirePath attributes on shared properties#60268

Merged
ArcturusZhang merged 3 commits into
mainfrom
arthurma/fix-wirepath-duplicate
Jun 26, 2026
Merged

[Mgmt] Fix duplicate WirePath attributes on shared properties#60268
ArcturusZhang merged 3 commits into
mainfrom
arthurma/fix-wirepath-duplicate

Conversation

@ArthurMa1978

Copy link
Copy Markdown
Member

Summary

Fix duplicate [WirePath] attributes emitted on shared model properties.

Root cause

WirePathVisitor.VisitProperty unconditionally appended a WirePathAttribute on every visit. When @@Azure.ClientGenerator.Core.Legacy.hierarchyBuilding reparents many models to a common base (e.g. Azure.ResourceManager.CommonTypes.ProxyResource), the same inherited PropertyProvider instance (such as Kind) is encountered once per descendant model during the visitor traversal. Each visit mutated the shared property by appending another WirePathAttribute, producing dozens of [WirePath("kind")] attributes on a single property.

Fix

Guard the append by checking whether a WirePathAttribute of the expected type is already present on the property.

Validation

Regenerated Azure.ResourceManager.AppService (which now uses hierarchyBuilding for 50+ models extending ProxyOnlyResource). The duplicate [WirePath("kind")] attributes are gone — a single attribute is emitted as expected.

WirePathVisitor unconditionally appended a WirePathAttribute on every visit. When hierarchyBuilding causes a PropertyProvider instance to be shared across many models (e.g. the inherited Kind property), the visitor encountered the same property once per descendant model and appended a duplicate attribute each time, producing dozens of [WirePath("""kind""")] attributes on the property.

Guard the append by checking whether a WirePathAttribute is already present on the property.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 15:42
@github-actions github-actions Bot added CodeGen Issues that relate to code generation Mgmt This issue is related to a management-plane library. labels Jun 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the management-plane generator to prevent emitting duplicate [WirePath] attributes when the same PropertyProvider instance is encountered multiple times during visitor traversal (e.g., with hierarchyBuilding-based shared base models).

Changes:

  • Adds a pre-check in WirePathVisitor.VisitProperty to skip appending a WirePath attribute if one already exists.

Address review comment: AttributeStatement.Type can throw for source-parsed attributes and may have a different CSharpType instance. Reuse the exception-safe IsWirePathAttribute helper which also has a name fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ArthurMa1978

Copy link
Copy Markdown
Member Author

Switched the duplicate guard to reuse FlattenPropertyVisitor.IsWirePathAttribute, which wraps the �ttribute.Type access in try/catch and falls back to a name comparison for source-parsed/customization attributes that may not bind to the same CSharpType instance. Thanks!

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ArcturusZhang ArcturusZhang merged commit 5b14064 into main Jun 26, 2026
28 checks passed
@ArcturusZhang ArcturusZhang deleted the arthurma/fix-wirepath-duplicate branch June 26, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CodeGen Issues that relate to code generation Mgmt This issue is related to a management-plane library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants