From c31ee70389474356b7895ea5d8327f709554166a Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:53:45 -0400 Subject: [PATCH] [tcgc] add crossLanguagePackageId (#649) Co-authored-by: iscai-msft --- .chronus/changes/add_package_id-2024-3-9-18-55-43.md | 7 +++++++ packages/typespec-client-generator-core/src/interfaces.ts | 1 + packages/typespec-client-generator-core/src/package.ts | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 .chronus/changes/add_package_id-2024-3-9-18-55-43.md diff --git a/.chronus/changes/add_package_id-2024-3-9-18-55-43.md b/.chronus/changes/add_package_id-2024-3-9-18-55-43.md new file mode 100644 index 0000000000..b9354a9c21 --- /dev/null +++ b/.chronus/changes/add_package_id-2024-3-9-18-55-43.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +add `.crossLanguagePackageId` onto `SdkContext` types. This is a package id that is shared across languages, allowing linkage between packages generated across different languages \ No newline at end of file diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index e8bee5d160..c881b5f424 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -546,6 +546,7 @@ export interface SdkPackage { * @deprecated This property is deprecated. Look at `.diagnostics` on SdkContext instead */ diagnostics: readonly Diagnostic[]; + crossLanguagePackageId: string; } export type SdkHttpPackage = SdkPackage; diff --git a/packages/typespec-client-generator-core/src/package.ts b/packages/typespec-client-generator-core/src/package.ts index 356dd5cabb..3e5768da38 100644 --- a/packages/typespec-client-generator-core/src/package.ts +++ b/packages/typespec-client-generator-core/src/package.ts @@ -59,6 +59,7 @@ import { import { createDiagnostic } from "./lib.js"; import { getClientNamespaceString, + getCrossLanguagePackageId, getDefaultApiVersion, getEffectivePayloadType, getHttpOperationWithCache, @@ -562,6 +563,7 @@ export function getSdkPackage< for (const client of listClients(context)) { createSdkClientType(context, client); } + const crossLanguagePackageId = diagnostics.pipe(getCrossLanguagePackageId(context)); return { name: getClientNamespaceString(context)!, rootNamespace: getClientNamespaceString(context)!, @@ -569,5 +571,6 @@ export function getSdkPackage< models: modelsAndEnums.filter((x): x is SdkModelType => x.kind === "model"), enums: modelsAndEnums.filter((x): x is SdkEnumType => x.kind === "enum"), diagnostics: diagnostics.diagnostics, + crossLanguagePackageId, }; }