Skip to content

Commit d5fb687

Browse files
committed
address review comments.
1 parent 7169709 commit d5fb687

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,21 @@ private IReadOnlyList<MethodBodyStatement> BuildLroHandling(
370370
var statements = new List<MethodBodyStatement>();
371371

372372
var finalStateVia = method.GetOperationFinalStateVia();
373-
var responseBodyInputType = method.GetResponseBodyInputType();
374-
var isNullBody = responseBodyInputType == null;
373+
var isGeneric = method.GetResponseBodyType == null;
375374

376-
var armOperationType = isNullBody
375+
var armOperationType = isGeneric
377376
? ManagementClientGenerator.Instance.OutputLibrary.ArmOperation.Type
378377
: ManagementClientGenerator.Instance.OutputLibrary.GenericArmOperation.Type.MakeGenericType([resourceClientType]);
379378

380379
ValueExpression[] armOperationArguments = [
381380
_clientDiagnosticsField,
382381
This.Property("Pipeline"),
383382
messageVariable.Property("Request"),
384-
isNullBody ? responseVariable : responseVariable.Invoke("GetRawResponse"),
383+
isGeneric ? responseVariable : responseVariable.Invoke("GetRawResponse"),
385384
Static(typeof(OperationFinalStateVia)).Property(finalStateVia.ToString())
386385
];
387386

388-
var operationInstanceArguments = isNullBody
387+
var operationInstanceArguments = isGeneric
389388
? armOperationArguments
390389
: [New.Instance(operationSourceType, armClientProperty), .. armOperationArguments];
391390

@@ -395,8 +394,8 @@ private IReadOnlyList<MethodBodyStatement> BuildLroHandling(
395394
var waitIfCompletedStatement = new IfStatement(KnownAzureParameters.WaitUntil.Equal(Static(typeof(WaitUntil)).Property(nameof(WaitUntil.Completed))))
396395
{
397396
isAsync
398-
? operationVariable.Invoke(isNullBody ? "WaitForCompletionResponseAsync" : "WaitForCompletionAsync", [cancellationTokenParameter], null, isAsync).Terminate()
399-
: operationVariable.Invoke(isNullBody ? "WaitForCompletionResponse" : "WaitForCompletion", cancellationTokenParameter).Terminate()
397+
? operationVariable.Invoke(isGeneric ? "WaitForCompletionResponseAsync" : "WaitForCompletionAsync", [cancellationTokenParameter], null, isAsync).Terminate()
398+
: operationVariable.Invoke(isGeneric ? "WaitForCompletionResponse" : "WaitForCompletion", cancellationTokenParameter).Terminate()
400399
};
401400
statements.Add(waitIfCompletedStatement);
402401

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@
88

99
namespace Azure.Generator.Management.Utilities
1010
{
11-
internal static class InputMethodExtensions
11+
internal static class InputServiceMethodExtensions
1212
{
1313
public static bool IsLongRunningOperation(this InputServiceMethod method)
1414
{
1515
return method is InputLongRunningServiceMethod || method is InputLongRunningPagingServiceMethod;
1616
}
1717

18-
public static InputType? GetResponseBodyInputType(this InputServiceMethod method)
19-
{
20-
var operationResponses = method.Operation.Responses;
21-
var response = operationResponses.FirstOrDefault(r => !r.IsErrorResponse);
22-
return response?.BodyType;
23-
}
24-
2518
public static OperationFinalStateVia GetOperationFinalStateVia(this InputServiceMethod method)
2619
{
2720
if (method is InputLongRunningServiceMethod lroMethod)
@@ -35,16 +28,18 @@ public static OperationFinalStateVia GetOperationFinalStateVia(this InputService
3528
return OperationFinalStateVia.Location;
3629
}
3730

38-
public static CSharpType? GetResponseBodyCSharpType(this InputServiceMethod method)
31+
public static CSharpType? GetResponseBodyType(this InputServiceMethod method)
3932
{
40-
var responseBodyType = method.GetResponseBodyInputType();
33+
var operationResponses = method.Operation.Responses;
34+
var response = operationResponses.FirstOrDefault(r => !r.IsErrorResponse);
35+
var responseBodyType = response?.BodyType;
4136
return responseBodyType is null ? null : ManagementClientGenerator.Instance.TypeFactory.CreateCSharpType(responseBodyType);
4237
}
4338

4439
public static CSharpType GetOperationMethodReturnType(this InputServiceMethod method, bool isAsync, CSharpType resourceClientCSharpType, CSharpType resourceDataType)
4540
{
4641
bool isLongRunningOperation = method.IsLongRunningOperation();
47-
var responseBodyCSharpType = method.GetResponseBodyCSharpType();
42+
var responseBodyCSharpType = method.GetResponseBodyType();
4843
CSharpType rawReturnType = method.GetOperationMethodRawReturnType(resourceClientCSharpType, resourceDataType);
4944

5045
if (isLongRunningOperation)
@@ -63,7 +58,7 @@ public static CSharpType GetOperationMethodReturnType(this InputServiceMethod me
6358

6459
private static CSharpType GetOperationMethodRawReturnType(this InputServiceMethod method, CSharpType resourceClientCSharpType, CSharpType resourceDataType)
6560
{
66-
var responseBodyCSharpType = method.GetResponseBodyCSharpType();
61+
var responseBodyCSharpType = method.GetResponseBodyType();
6762
CSharpType genericReturnType = resourceClientCSharpType;
6863

6964
if (responseBodyCSharpType is not null && responseBodyCSharpType != resourceDataType)

0 commit comments

Comments
 (0)