-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Support multiple-path resources with same resource model in MPG generator #54445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: live1206 <[email protected]>
Co-authored-by: live1206 <[email protected]>
…assing Co-authored-by: live1206 <[email protected]>
Co-authored-by: live1206 <[email protected]>
live1206
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot fix linter error:
/mnt/vss/work/1/s/eng/packages/http-client-csharp-mgmt/emitter/src/resource-detection.ts
106:36 error '' is assigned a value but never used @typescript-eslint/no-unused-vars
| @@ -0,0 +1,48 @@ | |||
| Microsoft Visual Studio Solution File, Format Version 12.00 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the output folder
Re-generate mgmt test to update generated code in https://github.com/Azure/azure-sdk-for-net/tree/main/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 676fb72. Removed the tsp-output folder and regenerated the test project. Generated code is now in src/Generated including the new Practice and PracticeVersion resources.
- Remove unused variable '_' from resource-detection.ts (line 106) - Remove tsp-output folder and regenerate test in correct location (src/Generated) - All emitter tests passing (9/9) Co-authored-by: live1206 <[email protected]>
|
|
||
| /** A practice resource model */ | ||
| @tenantResource | ||
| model Practice is ProxyResource<PracticeProperties> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot The scenario is not the same as https://github.com/Azure/typespec-azure/blob/32292dabd9a4741b02a211fe3838a7279961f690/packages/samples/specs/resource-manager/legacy/legacy-operations/main.tsp#L49-L107
we should use Azure.ResourceManager.Legacy.LegacyOperations, and there should be 2 resources sharing the same model.
Description
The MPG emitter previously keyed resource metadata by model ID alone, causing methods from different resource paths sharing the same model to merge incorrectly. This prevented scenarios like the typespec-azure legacy-operations pattern where two interfaces (
BestPractices,BestPracticeVersions) use the same model (BestPractice) at different paths.Changes
Emitter (
resource-detection.ts)modelId + resourcePathinstead of model ID alonePractices→Practice,PracticeVersions→PracticeVersion)Tests
multiplepaths.tspdemonstrating parent/child resourcesTest Project
src/Generated)tsp-outputfolderExample
TypeSpec defining two resources sharing the same properties:
Now generates separate
PracticeResourceandPracticeVersionResourceclasses with distinct paths:/providers/.../practices/{practiceName}/providers/.../practices/{practiceName}/practiceVersions/{practiceVersionName}This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Testing Guidelines
SDK Generation Guidelines
*.csprojandAssemblyInfo.csfiles have been updated with the new version of the SDK.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.