Skip to content

Commit

Permalink
[tcgc] add crossLanguagePackageId (Azure#649)
Browse files Browse the repository at this point in the history
Co-authored-by: iscai-msft <[email protected]>
  • Loading branch information
iscai-msft and iscai-msft authored Apr 11, 2024
1 parent b5d6238 commit c31ee70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/add_package_id-2024-3-9-18-55-43.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions packages/typespec-client-generator-core/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ export interface SdkPackage<TServiceOperation extends SdkServiceOperation> {
* @deprecated This property is deprecated. Look at `.diagnostics` on SdkContext instead
*/
diagnostics: readonly Diagnostic[];
crossLanguagePackageId: string;
}

export type SdkHttpPackage = SdkPackage<SdkHttpOperation>;
Expand Down
3 changes: 3 additions & 0 deletions packages/typespec-client-generator-core/src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
import { createDiagnostic } from "./lib.js";
import {
getClientNamespaceString,
getCrossLanguagePackageId,
getDefaultApiVersion,
getEffectivePayloadType,
getHttpOperationWithCache,
Expand Down Expand Up @@ -562,12 +563,14 @@ 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)!,
clients: Array.from(context.__clients.values()),
models: modelsAndEnums.filter((x): x is SdkModelType => x.kind === "model"),
enums: modelsAndEnums.filter((x): x is SdkEnumType => x.kind === "enum"),
diagnostics: diagnostics.diagnostics,
crossLanguagePackageId,
};
}

0 comments on commit c31ee70

Please sign in to comment.