Skip to content

Commit 81aaf4a

Browse files
[Azure Mgmt Generator] Fix method ordering to put async methods first across all providers (#51835)
* Initial plan * Fix method ordering in Azure Management Generator - async methods now come first Co-authored-by: ArcturusZhang <[email protected]> * Fix method ordering in ResourceCollectionClientProvider and MockableResourceProvider - async methods now come first Co-authored-by: ArcturusZhang <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ArcturusZhang <[email protected]>
1 parent 2dd6186 commit 81aaf4a

File tree

10 files changed

+155
-155
lines changed

10 files changed

+155
-155
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ protected override MethodProvider[] BuildMethods()
173173
foreach (var method in _methods)
174174
{
175175
// add the method provider one by one.
176-
methods.Add(BuildNonResourceMethod(method, false));
177176
methods.Add(BuildNonResourceMethod(method, true));
177+
methods.Add(BuildNonResourceMethod(method, false));
178178
}
179179

180180
return [.. methods];
@@ -225,16 +225,16 @@ private IEnumerable<MethodProvider> BuildMethodsForResource(ResourceClientProvid
225225
// find the method
226226
var getMethod = collection.Methods.FirstOrDefault(m => m.Signature.Name == "Get");
227227
var getAsyncMethod = collection.Methods.FirstOrDefault(m => m.Signature.Name == "GetAsync");
228-
if (getMethod is not null)
228+
if (getAsyncMethod is not null)
229229
{
230230
// we should be sure that this would never be null, but this null check here is just ensuring that we never crash
231-
yield return BuildGetMethod(this, getMethod, collectionMethodSignature, $"Get{resource.ResourceName}");
231+
yield return BuildGetMethod(this, getAsyncMethod, collectionMethodSignature, $"Get{resource.ResourceName}Async");
232232
}
233233

234-
if (getAsyncMethod is not null)
234+
if (getMethod is not null)
235235
{
236236
// we should be sure that this would never be null, but this null check here is just ensuring that we never crash
237-
yield return BuildGetMethod(this, getAsyncMethod, collectionMethodSignature, $"Get{resource.ResourceName}Async");
237+
yield return BuildGetMethod(this, getMethod, collectionMethodSignature, $"Get{resource.ResourceName}");
238238
}
239239

240240
static MethodProvider BuildGetMethod(TypeProvider enclosingType, MethodProvider resourceGetMethod, MethodSignature collectionGetSignature, string methodName)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ protected override MethodProvider[] BuildMethods()
356356
if (method is InputPagingServiceMethod pagingMethod)
357357
{
358358
// Use PageableOperationMethodProvider for InputPagingServiceMethod
359-
operationMethods.Add(new PageableOperationMethodProvider(this, _contextualPath, restClientInfo, pagingMethod, false, methodName: ResourceHelpers.GetOperationMethodName(methodKind, false)));
360359
operationMethods.Add(new PageableOperationMethodProvider(this, _contextualPath, restClientInfo, pagingMethod, true, methodName: ResourceHelpers.GetOperationMethodName(methodKind, true)));
360+
operationMethods.Add(new PageableOperationMethodProvider(this, _contextualPath, restClientInfo, pagingMethod, false, methodName: ResourceHelpers.GetOperationMethodName(methodKind, false)));
361361

362362
continue;
363363
}
@@ -367,18 +367,18 @@ protected override MethodProvider[] BuildMethods()
367367

368368
if (isUpdateOperation)
369369
{
370-
updateMethodProvider = new UpdateOperationMethodProvider(this, _contextualPath, restClientInfo, method, false);
371-
operationMethods.Add(updateMethodProvider);
372-
373370
var updateAsyncMethodProvider = new UpdateOperationMethodProvider(this, _contextualPath, restClientInfo, method, true);
374371
operationMethods.Add(updateAsyncMethodProvider);
372+
373+
updateMethodProvider = new UpdateOperationMethodProvider(this, _contextualPath, restClientInfo, method, false);
374+
operationMethods.Add(updateMethodProvider);
375375
}
376376
else
377377
{
378-
var methodName = ResourceHelpers.GetOperationMethodName(methodKind, false);
379-
operationMethods.Add(new ResourceOperationMethodProvider(this, _contextualPath, restClientInfo, method, false, methodName, forceLro: isFakeLro));
380378
var asyncMethodName = ResourceHelpers.GetOperationMethodName(methodKind, true);
381379
operationMethods.Add(new ResourceOperationMethodProvider(this, _contextualPath, restClientInfo, method, true, asyncMethodName, forceLro: isFakeLro));
380+
var methodName = ResourceHelpers.GetOperationMethodName(methodKind, false);
381+
operationMethods.Add(new ResourceOperationMethodProvider(this, _contextualPath, restClientInfo, method, false, methodName, forceLro: isFakeLro));
382382
}
383383
}
384384

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

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

0 commit comments

Comments
 (0)