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

prevent tcgc versioning projection #745

Merged
merged 13 commits into from
May 6, 2024
7 changes: 7 additions & 0 deletions .chronus/changes/autorest_update-2024-3-26-10-54-52.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-autorest"
---

prevent tcgc versioning projection
7 changes: 7 additions & 0 deletions .chronus/changes/autorest_update-2024-3-30-11-46-5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

allow callers of createSdkContext to ignore default version projection
4 changes: 3 additions & 1 deletion packages/typespec-autorest/src/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export async function $onEmit(context: EmitContext<AutorestEmitterOptions>) {
const tracer = getTracer(context.program);
tracer.trace("options", JSON.stringify(options, null, 2));

const tcgcSdkContext = createSdkContext(context, "@azure-tools/typespec-autorest");
const tcgcSdkContext = createSdkContext(context, "@azure-tools/typespec-autorest", {
versionStrategy: "ignore",
});

await emitAllServiceAtAllVersions(context.program, tcgcSdkContext, options);
}
Expand Down
12 changes: 10 additions & 2 deletions packages/typespec-client-generator-core/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,18 @@ export function listOperationsInOperationGroup(
return operations;
}

interface CreateSdkContextOptions {
readonly versionStrategy?: "ignore";
}

export function createSdkContext<
TOptions extends Record<string, any> = SdkEmitterOptions,
TServiceOperation extends SdkServiceOperation = SdkHttpOperation,
>(context: EmitContext<TOptions>, emitterName?: string): SdkContext<TOptions, TServiceOperation> {
>(
context: EmitContext<TOptions>,
emitterName?: string,
options?: CreateSdkContextOptions
): SdkContext<TOptions, TServiceOperation> {
const diagnostics = createDiagnosticCollector();
const protocolOptions = true; // context.program.getLibraryOptions("generate-protocol-methods");
const convenienceOptions = true; // context.program.getLibraryOptions("generate-convenience-methods");
Expand All @@ -594,7 +602,7 @@ export function createSdkContext<
packageName: context.options["package-name"],
flattenUnionAsEnum: context.options["flatten-union-as-enum"] ?? true,
diagnostics: diagnostics.diagnostics,
apiVersion: context.options["api-version"],
apiVersion: options?.versionStrategy === "ignore" ? "all" : context.options["api-version"],
originalProgram: context.program,
};
sdkContext.experimental_sdkPackage = getSdkPackage(sdkContext);
Expand Down
Loading