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

[tcgc] support new typespec emitter naming rule #947

Merged
merged 2 commits into from
Jun 4, 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
7 changes: 7 additions & 0 deletions .chronus/changes/emitter_name-2024-5-3-22-57-49.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

support new typespec emitter naming rule
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function parseEmitterName(
);
return diagnostics.wrap("none");
}
const regex = /(?:cadl|typespec)-([^\\/]*)/;
const regex = /(?:cadl|typespec|client|server)-([^\\/-]*)/;
const match = emitterName.match(regex);
if (!match || match.length < 2) return diagnostics.wrap("none");
const language = match[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ describe("typespec-client-generator-core: internal-utils", () => {
strictEqual(docHelper.details, "This is a description");
});
});
describe("parseEmitterName", () => {
it("@azure-tools/typespec-{language}", async () => {
const runner = await createSdkTestRunner({ emitterName: "@azure-tools/typespec-csharp" });
await runner.compile("");
strictEqual(runner.context.emitterName, "csharp");
});

it("@typespec/{protocol}-{client|server}-{language}-generator", async () => {
const runner = await createSdkTestRunner({ emitterName: "@typespec/http-client-csharp" });
await runner.compile("");
strictEqual(runner.context.emitterName, "csharp");
});
});
});
Loading