Skip to content

Commit 770af35

Browse files
Fix field naming and upgrade MTG (Azure#50732)
* Fix field naming and upgrade MTG * regen * missed regen
1 parent 386d829 commit 770af35

File tree

35 files changed

+2068
-519
lines changed

35 files changed

+2068
-519
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@
450450

451451
<PropertyGroup>
452452
<TestProxyVersion>1.0.0-dev.20250501.1</TestProxyVersion>
453-
<UnbrandedGeneratorVersion>1.0.0-alpha.20250618.1</UnbrandedGeneratorVersion>
453+
<UnbrandedGeneratorVersion>1.0.0-alpha.20250619.2</UnbrandedGeneratorVersion>
454454
<AzureGeneratorVersion>1.0.0-alpha.20250527.2</AzureGeneratorVersion>
455455
</PropertyGroup>
456456
</Project>

eng/packages/http-client-csharp/generator/Azure.Generator/src/Properties/launchSettings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
"commandName": "Executable",
5151
"executablePath": "dotnet"
5252
},
53+
"http-azure-resource-manager-large-header": {
54+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/large-header -g AzureStubGenerator",
55+
"commandName": "Executable",
56+
"executablePath": "dotnet"
57+
},
5358
"http-azure-special-headers-client-request-id": {
5459
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/special-headers/client-request-id -g AzureStubGenerator",
5560
"commandName": "Executable",

eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/CollectionResultDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public CollectionResultDefinition(ClientProvider client, InputPagingServiceMetho
8484
var field = new FieldProvider(
8585
FieldModifiers.Private | FieldModifiers.ReadOnly,
8686
parameter.Type,
87-
$"_{parameter.Name}",
87+
$"_{parameter.Name.ToVariableName()}",
8888
this);
8989
fields.Add(field);
9090
if (field.Name == "_context")

eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/NextLinkTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
45
using Azure.Generator.Providers;
56
using Azure.Generator.Tests.Common;
67
using Azure.Generator.Tests.TestHelpers;
@@ -153,6 +154,42 @@ public void NextLinkInBodyMultipleClients()
153154
Assert.IsNotNull(felineClientCollectionResult);
154155
}
155156

157+
[Test]
158+
public void UsesValidFieldIdentifierNames()
159+
{
160+
MockHelpers.LoadMockPlugin();
161+
var inputModel = InputFactory.Model("cat", properties:
162+
[
163+
InputFactory.Property("color", InputPrimitiveType.String, isRequired: true),
164+
]);
165+
var pagingMetadata = InputFactory.NextLinkPagingMetadata("cats", "nextCat", InputResponseLocation.Body);
166+
var response = InputFactory.OperationResponse(
167+
[200],
168+
InputFactory.Model(
169+
"page",
170+
properties:
171+
[
172+
InputFactory.Property("cats", InputFactory.Array(inputModel)),
173+
InputFactory.Property("nextCat", InputPrimitiveType.Url)
174+
]));
175+
IReadOnlyList<InputParameter> parameters =
176+
[
177+
InputFactory.Parameter("$foo", InputPrimitiveType.String, isRequired: true,
178+
location: InputRequestLocation.Header)
179+
];
180+
var operation = InputFactory.Operation("getCats", responses: [response], parameters: parameters);
181+
var inputServiceMethod = InputFactory.PagingServiceMethod("getCats", operation,
182+
pagingMetadata: pagingMetadata, parameters: parameters);
183+
var catClient = InputFactory.Client("catClient", methods: [inputServiceMethod], clientNamespace: "Cats");
184+
var clientProvider = AzureClientGenerator.Instance.TypeFactory.CreateClient(catClient);
185+
var modelType = AzureClientGenerator.Instance.TypeFactory.CreateModel(inputModel);
186+
var collectionResultDefinition =
187+
new CollectionResultDefinition(clientProvider!, inputServiceMethod, modelType!.Type, false);
188+
var fields = collectionResultDefinition.Fields;
189+
190+
Assert.IsTrue(fields.Any(f => f.Name == "_foo"));
191+
}
192+
156193
private static void CreatePagingOperation(InputResponseLocation responseLocation)
157194
{
158195
var inputModel = InputFactory.Model("cat", properties:

eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClient.RestClient.cs

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

eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs

Lines changed: 1 addition & 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/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs

Lines changed: 1 addition & 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/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithContinuationTokenCollectionResult.cs

Lines changed: 1 addition & 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/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs

Lines changed: 1 addition & 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/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs

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

0 commit comments

Comments
 (0)