-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Replace ResourceDataProvdier with ResoruceVisitor #48362
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
78039cb
Replace ResourceDataProvdier with ResoruceVisitor
live1206 3210a5e
update MGC and fix renaming
live1206 dfe069e
update
live1206 3d05fd6
update lock file
live1206 216654c
update
live1206 86050c2
update test
live1206 b8f8a20
Address comments
live1206 c301d2e
remvoe unnecessary override
live1206 355bf08
update tests
live1206 819d7ba
update
live1206 84afbf5
update visitor methods
live1206 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
23 changes: 0 additions & 23 deletions
23
...ckages/http-client-csharp/generator/Azure.Generator/src/Providers/ResourceDataProvider.cs
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
...lient-csharp/generator/Azure.Generator/src/Providers/ResourceDataSerializationProvider.cs
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
eng/packages/http-client-csharp/generator/Azure.Generator/src/ResourceVisitor.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.TypeSpec.Generator.ClientModel; | ||
| using Microsoft.TypeSpec.Generator.Input; | ||
| using Microsoft.TypeSpec.Generator.Providers; | ||
| using System.IO; | ||
|
|
||
| namespace Azure.Generator | ||
| { | ||
| internal class ResourceVisitor : ScmLibraryVisitor | ||
| { | ||
| protected override ModelProvider? Visit(InputModelType model, ModelProvider? type) | ||
| { | ||
| if (type is not null) | ||
| { | ||
| TransformResource(type); | ||
| } | ||
| return type; | ||
| } | ||
|
|
||
| protected override TypeProvider? Visit(TypeProvider type) | ||
| { | ||
| TransformResource(type); | ||
| return type; | ||
| } | ||
|
|
||
| private static void TransformResource(TypeProvider type) | ||
| { | ||
| if (type is ModelProvider && AzureClientPlugin.Instance.OutputLibrary.IsResource(type.Name)) | ||
| { | ||
| type.RelativeFilePath = TransformRelativeFilePath(type); | ||
| type.Type.Name = TransformName(type); | ||
| foreach (var serialization in type.SerializationProviders) | ||
| { | ||
| serialization.RelativeFilePath = TransformRelativeFilePathForSerialization(serialization); | ||
| serialization.Type.Name = TransformName(serialization); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static string TransformName(TypeProvider model) => $"{model.Name}Data"; | ||
|
|
||
| private static string TransformRelativeFilePath(TypeProvider model) | ||
| => Path.Combine("src", "Generated", $"{TransformName(model)}.cs"); | ||
|
|
||
| private static string TransformRelativeFilePathForSerialization(TypeProvider model) | ||
| => Path.Combine("src", "Generated", $"{TransformName(model)}.Serialization.cs"); | ||
| } | ||
| } |
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
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
44 changes: 0 additions & 44 deletions
44
.../http-client-csharp/generator/Azure.Generator/test/Providers/ResourceDataProviderTests.cs
This file was deleted.
Oops, something went wrong.
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
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
3 changes: 1 addition & 2 deletions
3
...ackages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/Configuration.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| { | ||
| "output-folder": ".", | ||
| "namespace": "BasicTypeSpec", | ||
| "library-name": "BasicTypeSpec" | ||
| "package-name": "BasicTypeSpec" | ||
| } |
3 changes: 1 addition & 2 deletions
3
...packages/http-client-csharp/generator/TestProjects/Local/Mgmt-TypeSpec/Configuration.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| { | ||
| "output-folder": ".", | ||
| "namespace": "MgmtTypeSpec", | ||
| "library-name": "MgmtTypeSpec" | ||
| "package-name": "MgmtTypeSpec" | ||
| } |
6 changes: 3 additions & 3 deletions
6
...harp/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.