[Mgmt] Fix duplicate WirePath attributes on shared properties#60268
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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.VisitPropertyto skip appending aWirePathattribute 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>
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! |
ArcturusZhang
approved these changes
Jun 26, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ArcturusZhang
approved these changes
Jun 26, 2026
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
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 anotherWirePathAttribute, producing dozens of[WirePath("kind")]attributes on a single property.Fix
Guard the append by checking whether a
WirePathAttributeof the expected type is already present on the property.Validation
Regenerated
Azure.ResourceManager.AppService(which now useshierarchyBuildingfor 50+ models extendingProxyOnlyResource). The duplicate[WirePath("kind")]attributes are gone — a single attribute is emitted as expected.