Skip to content

Commit 5511890

Browse files
authored
support replacing inputModel with SubResource in management generator. (Azure#51593)
* support replacing inputModel with SubResource in management generator.
1 parent f6016b6 commit 5511890

File tree

14 files changed

+2086
-937
lines changed

14 files changed

+2086
-937
lines changed

eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Primitives/KnownManagementTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ internal class KnownManagementTypes
4444
["Azure.ResourceManager.CommonTypes.OperationStatusResult"] = typeof(OperationStatusResult),
4545
["Azure.ResourceManager.CommonTypes.SystemData"] = typeof(SystemData),
4646
["Azure.ResourceManager.CommonTypes.UserAssignedIdentity"] = typeof(UserAssignedIdentity),
47+
["Azure.ResourceManager.Models.SubResource"] = typeof(SubResource),
4748
};
4849

4950
private static readonly Dictionary<string, CSharpType> _idToPrimitiveTypeMap = new Dictionary<string, CSharpType>()

eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/OperationMethodProviders/PageableOperationMethodProvider.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ internal class PageableOperationMethodProvider
2828
private readonly bool _isAsync;
2929
private readonly CSharpType _itemType;
3030
private readonly ResourceOperationKind _methodKind;
31+
private readonly MethodSignature _signature;
32+
private readonly MethodBodyStatement[] _bodyStatements;
3133

3234
public PageableOperationMethodProvider(
3335
TypeProvider enclosingType,
@@ -47,13 +49,15 @@ public PageableOperationMethodProvider(
4749
_isAsync = isAsync;
4850
_itemType = itemType;
4951
_methodKind = methodKind;
52+
_signature = CreateSignature();
53+
_bodyStatements = BuildBodyStatements();
5054
}
5155

5256
public static implicit operator MethodProvider(PageableOperationMethodProvider pageableOperationMethodProvider)
5357
{
5458
return new MethodProvider(
55-
pageableOperationMethodProvider.CreateSignature(),
56-
pageableOperationMethodProvider.BuildBodyStatements(),
59+
pageableOperationMethodProvider._signature,
60+
pageableOperationMethodProvider._bodyStatements,
5761
pageableOperationMethodProvider._enclosingType);
5862
}
5963

@@ -95,7 +99,7 @@ protected MethodBodyStatement[] BuildBodyStatements()
9599
{
96100
_restClientInfo.RestClientField,
97101
};
98-
arguments.AddRange(_contextualPath.PopulateArguments(This.As<ArmResource>().Id(), requestMethod.Signature.Parameters, contextVariable, _convenienceMethod.Signature.Parameters));
102+
arguments.AddRange(_contextualPath.PopulateArguments(This.As<ArmResource>().Id(), requestMethod.Signature.Parameters, contextVariable, _signature.Parameters));
99103

100104
// Handle ResourceData type conversion if needed
101105
if (IsResourceDataType(_itemType))

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecContext.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.Serialization.cs

Lines changed: 190 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.cs

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/ZoosRestOperations.cs

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZooCollection.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)