diff --git a/.chronus/changes/tcgc-fix-lro-regression-2026-0-14-14-18-31.md b/.chronus/changes/tcgc-fix-lro-regression-2026-0-14-14-18-31.md new file mode 100644 index 0000000000..bcd323b4bb --- /dev/null +++ b/.chronus/changes/tcgc-fix-lro-regression-2026-0-14-14-18-31.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +Refine diagnostic for LRO and paging metadata generation. \ No newline at end of file diff --git a/packages/typespec-client-generator-core/src/methods.ts b/packages/typespec-client-generator-core/src/methods.ts index a9e0421417..9f9b490996 100644 --- a/packages/typespec-client-generator-core/src/methods.ts +++ b/packages/typespec-client-generator-core/src/methods.ts @@ -268,7 +268,7 @@ function getSdkPagingServiceMethod { ); }); }); + +it("versioned LRO with customization", async () => { + const runnerWithCore = await createSdkTestRunner({ + librariesToAdd: [AzureCoreTestLibrary], + autoUsings: ["Azure.Core", "Azure.Core.Traits"], + emitterName: "@azure-tools/typespec-java", + }); + await runnerWithCore.compileWithCustomization( + ` + @service + @versioned(Versions) + namespace TestService; + + enum Versions { + v1, + v2, + } + + alias TestOperations = ResourceOperations; + + @resource("id") + model TestResult { + @key + id: string; + + @lroStatus + status: JobStatus; + } + + @lroStatus + union JobStatus { + string, + NotStarted: "notStarted", + Running: "running", + + @lroSucceeded + Succeeded: "succeeded", + + @lroFailed + Failed: "failed", + + Canceled: "canceled", + } + + @get + op get is TestOperations.ResourceRead; + + @pollingOperation(get) + op create is TestOperations.LongRunningResourceCreateOrReplace; + `, + ` + @client({ + service: TestService, + }) + namespace TestClient; + + op test is TestService.create; + `, + ); + strictEqual(runnerWithCore.context.diagnostics.length, 0); + const client = runnerWithCore.context.sdkPackage.clients[0]; + strictEqual(client.methods.length, 1); + const method = client.methods[0]; + strictEqual(method.name, "test"); + strictEqual(method.kind, "lro"); + const lroMetadata = method.lroMetadata; + ok(lroMetadata); +});