Skip to content

Commit d4f330b

Browse files
authored
Bump MTG version for mgmt (Azure#49499)
1 parent 86cf218 commit d4f330b

File tree

28 files changed

+1838
-1074
lines changed

28 files changed

+1838
-1074
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
</ItemGroup>
207207

208208
<ItemGroup Condition="'$(IsGeneratorLibrary)' == 'true'">
209-
<PackageReference Update="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250421.4" />
209+
<PackageReference Update="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250422.2" />
210210
<PackageReference Update="System.ClientModel" Version="1.3.0" />
211211
</ItemGroup>
212212

eng/packages/http-client-csharp-mgmt/emitter/src/emitter.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
CodeModel,
99
InputClient,
1010
InputModelType,
11-
setSDKContextOptions
1211
} from "@typespec/http-client-csharp";
1312

1413
import {
@@ -30,7 +29,7 @@ export async function $onEmit(context: EmitContext<AzureEmitterOptions>) {
3029
context.options["update-code-model"] = updateCodeModel;
3130
context.options["emitter-extension-path"] ??= import.meta.url;
3231
context.options["sdk-context-options"] ??= azureSDKContextOptions;
33-
setSDKContextOptions(azureSDKContextOptions);
32+
context.options["model-namespace"] ??= true;
3433
await $onAzureEmit(context);
3534
}
3635

@@ -50,9 +49,9 @@ function updateCodeModel(codeModel: CodeModel): CodeModel {
5049
// A resource client should have decorator armResourceOperations and contains either a get operation(containing armResourceRead deocrator) or a put operation(containing armResourceCreateOrUpdate decorator)
5150
if (
5251
client.decorators?.some((d) => d.name == armResourceOperations) &&
53-
client.operations.some(
54-
(op) =>
55-
op.decorators?.some(
52+
client.methods.some(
53+
(m) =>
54+
m.operation.decorators?.some(
5655
(d) => d.name == armResourceRead || armResourceCreateOrUpdate
5756
)
5857
)
@@ -61,9 +60,9 @@ function updateCodeModel(codeModel: CodeModel): CodeModel {
6160
let isSingleton: boolean = false;
6261
let resourceType: string | undefined = undefined;
6362
// We will try to get resource metadata from put operation firstly, if not found, we will try to get it from get operation
64-
const putOperation = client.operations.find(
65-
(op) => op.decorators?.some((d) => d.name == armResourceCreateOrUpdate)
66-
);
63+
const putOperation = client.methods.find(
64+
(m) => m.operation.decorators?.some((d) => d.name == armResourceCreateOrUpdate)
65+
)?.operation;
6766
if (putOperation) {
6867
const path = putOperation.path;
6968
resourceType = calculateResourceTypeFromPath(path);
@@ -72,9 +71,9 @@ function updateCodeModel(codeModel: CodeModel): CodeModel {
7271
isSingleton =
7372
resourceModel.decorators?.some((d) => d.name == singleton) ?? false;
7473
} else {
75-
const getOperation = client.operations.find(
76-
(op) => op.decorators?.some((d) => d.name == armResourceRead)
77-
);
74+
const getOperation = client.methods.find(
75+
(m) => m.operation.decorators?.some((d) => d.name == armResourceRead)
76+
)?.operation;
7877
if (getOperation) {
7978
const path = getOperation.path;
8079
resourceType = calculateResourceTypeFromPath(path);

eng/packages/http-client-csharp-mgmt/emitter/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
export { $lib } from "./lib/lib.js";
5+
export { $onEmit } from "./emitter.js";

eng/packages/http-client-csharp-mgmt/emitter/src/sdk-context-options.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import { CreateSdkContextOptions } from "@azure-tools/typespec-client-generator-core";
55

66
export const azureSDKContextOptions: CreateSdkContextOptions = {
7-
versioning: {},
7+
versioning: {
8+
previewStringRegex: /-preview$/,
9+
},
810
additionalDecorators: [
911
// https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/README.md#usesystemtextjsonconverter
1012
"Azure\\.ClientGenerator\\.Core\\.@useSystemTextJsonConverter",

eng/packages/http-client-csharp-mgmt/eng/scripts/Generation.psm1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ function Get-Mgmt-TspCommand {
2525
[string]$specFile,
2626
[string]$generationDir,
2727
[bool]$generateStub = $false,
28-
[string]$apiVersion = $null,
29-
[bool]$forceNewProject = $false
28+
[string]$apiVersion = $null
3029
)
3130
$command = "npx tsp compile $specFile"
3231
$command += " --trace @azure-typespec/http-client-csharp-mgmt"
33-
$command += " --emit $repoRoot/../../http-client-csharp-mgmt"
34-
32+
$command += " --emit $repoRoot/.."
3533
$configFile = Join-Path $generationDir "tspconfig.yaml"
3634
if (Test-Path $configFile) {
3735
$command += " --config=$configFile"
@@ -46,9 +44,7 @@ function Get-Mgmt-TspCommand {
4644
$command += " --option @azure-typespec/http-client-csharp-mgmt.api-version=$apiVersion"
4745
}
4846

49-
if ($forceNewProject) {
50-
$command += " --option @azure-typespec/http-client-csharp-mgmt.new-project=true"
51-
}
47+
$command += " --option @azure-typespec/http-client-csharp-mgmt.new-project=true"
5248

5349
return $command
5450
}

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/Configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"output-folder": ".",
32
"package-name": "MgmtTypeSpec",
3+
"model-namespace": true,
44
"license": {
55
"name": "MIT License",
66
"company": "Microsoft Corporation",

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

Lines changed: 2 additions & 7 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/FooData.cs

Lines changed: 4 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/MgmtTypeSpecModelFactory.cs

Lines changed: 6 additions & 6 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/Resource.cs

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

0 commit comments

Comments
 (0)