Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to tcgc 0.44.3 #1411

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 87 additions & 99 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/typespec-go/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
"@azure-tools/cadl-ranch": "~0.13.4",
"@azure-tools/cadl-ranch-expect": "~0.14.1",
"@azure-tools/cadl-ranch-specs": "0.34.9",
"@azure-tools/typespec-autorest": "0.44.0",
"@azure-tools/typespec-autorest": "0.44.1",
"@azure-tools/typespec-azure-resource-manager": "0.44.0",
"@types/js-yaml": "~4.0.6",
"@types/node": "^18.16.3",
"@typescript-eslint/eslint-plugin": "~4.1.1",
"@typescript-eslint/parser": "~4.1.1",
"@typespec/openapi": "~0.57.0",
"@typespec/openapi": "~0.58.0",
"@types/jest": "~26.0.24",
"eslint": "~6.6.0",
"jest": "~27.0.6",
Expand All @@ -66,8 +66,8 @@
"@azure-tools/codegen": "~2.9.2",
"@azure-tools/linq": "~3.1.0",
"@azure-tools/typespec-azure-core": ">=0.44.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": "0.44.1",
"@typespec/compiler": "0.58.0",
"@azure-tools/typespec-client-generator-core": "0.44.3",
"@typespec/compiler": "0.58.1",
"@typespec/http": "0.58.0",
"@typespec/rest": "0.58.0",
"@typespec/versioning": "0.58.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-go/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EmitContext } from '@typespec/compiler';
import 'source-map-support/register.js';

export async function $onEmit(context: EmitContext<GoEmitterOptions>) {
const codeModel = tcgcToGoCodeModel(context);
const codeModel = await tcgcToGoCodeModel(context);
await mkdir(context.emitterOutputDir, {recursive: true});

// don't overwrite an existing go.mod file, update it if required
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-go/src/tcgcadapter/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const headerText = `Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See License.txt in the project root for license information.
Code generated by Microsoft (R) Go Code Generator.`;

export function tcgcToGoCodeModel(context: EmitContext<GoEmitterOptions>): go.CodeModel {
export async function tcgcToGoCodeModel(context: EmitContext<GoEmitterOptions>): Promise<go.CodeModel> {
const info = new go.Info('TODO Title');
const options = new go.Options(headerText, context.options['generate-fakes'] === true, context.options['inject-spans'] === true, context.options['disallow-unknown-fields'] === true);
if (context.options['azcore-version']) {
options.azcoreVersion = context.options['azcore-version'];
}

const sdkContext = tcgc.createSdkContext(context);
const sdkContext = await tcgc.createSdkContext(context);
let codeModelType: go.CodeModelType = 'data-plane';
if (sdkContext.arm === true) {
codeModelType = 'azure-arm';
Expand Down
35 changes: 11 additions & 24 deletions packages/typespec-go/src/tcgcadapter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,13 @@ export class typeAdapter {
getPossibleType(type: tcgc.SdkType, elementTypeByValue: boolean, substituteDiscriminator: boolean): go.PossibleType {
switch (type.kind) {
case 'any':
case 'armId':
case 'azureLocation':
case 'boolean':
case 'bytes':
case 'decimal':
case 'decimal128':
case 'eTag':
case 'float':
case 'float32':
case 'float64':
case 'guid':
case 'int8':
case 'int16':
case 'int32':
Expand All @@ -174,9 +170,7 @@ export class typeAdapter {
case 'plainDate':
case 'plainTime':
case 'string':
case 'uri':
case 'url':
case 'uuid':
return this.getBuiltInType(type);
case 'array': {
let elementType = type.valueType;
Expand Down Expand Up @@ -352,16 +346,6 @@ export class typeAdapter {
this.types.set(decimalKey, decimalType);
return decimalType;
}
case 'eTag': {
const etagKey = 'etag';
let etag = this.types.get(etagKey);
if (etag) {
return etag;
}
etag = new go.QualifiedType('ETag', 'github.com/Azure/azure-sdk-for-go/sdk/azcore');
this.types.set(etagKey, etag);
return etag;
}
case 'float': // C# and Java define float as 32 bits so we're following suit
case 'float32': {
const float32Key = 'float32';
Expand Down Expand Up @@ -400,13 +384,19 @@ export class typeAdapter {
this.types.set(keyName, intType);
return intType;
}
case 'armId':
case 'azureLocation':
case 'guid':
case 'string':
case 'uuid':
case 'uri':
case 'url': {
if (type.crossLanguageDefinitionId === 'Azure.Core.eTag') {
const etagKey = 'etag';
let etag = this.types.get(etagKey);
if (etag) {
return etag;
}
etag = new go.QualifiedType('ETag', 'github.com/Azure/azure-sdk-for-go/sdk/azcore');
this.types.set(etagKey, etag);
return etag;
}

const stringKey = 'string';
let stringType = this.types.get(stringKey);
if (stringType) {
Expand Down Expand Up @@ -734,9 +724,6 @@ export class typeAdapter {
return literalFloat;
}
case 'string':
case 'guid':
case 'uuid':
case 'uri':
case 'url': {
const keyName = `literal-string-${constType.value}`;
let literalString = this.types.get(keyName);
Expand Down
Loading