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] Adopt the Microsoft emitter name format when pass the emitter name to get the language #937

Closed
chunyu3 opened this issue May 30, 2024 · 0 comments · Fixed by #947
Closed
Assignees
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@chunyu3
Copy link
Member

chunyu3 commented May 30, 2024

There are a set of Microsoft emitter whose name convention is @typespec/{protocol}-{client|server}-{language}-{framework} and {framework} part is optional. for example, the csharp emitter name will be @typespec/http-client-csharp. (see loop typespec's codegen ecosystem

TCGC now only adopt "@azure-tools/typespec-{language}" format to parse emitter name( see following). Need to adopt the new emitter name format.

export function parseEmitterName(
  program: Program,
  emitterName?: string
): [string, readonly Diagnostic[]] {
  const diagnostics = createDiagnosticCollector();
  if (!emitterName) {
    diagnostics.add(
      createDiagnostic({
        code: "no-emitter-name",
        format: {},
        target: program.getGlobalNamespaceType(),
      })
    );
    return diagnostics.wrap("none");
  }
  const regex = /(?:cadl|typespec)-([^\\/]*)/;
  const match = emitterName.match(regex);
  if (!match || match.length < 2) return diagnostics.wrap("none");
  const language = match[1];
  if (["typescript", "ts"].includes(language)) return diagnostics.wrap("javascript");
  return diagnostics.wrap(language);
}

Expected:
TCGC adopt the new emitter name format and parse out the language from emitter name.

@chunyu3 chunyu3 added lib:tcgc Issues for @azure-tools/typespec-client-generator-core library and removed needs-area labels May 30, 2024
@tadelesh tadelesh self-assigned this Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants