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] namespaces in TCGC #1604

Open
4 tasks done
iscai-msft opened this issue Sep 24, 2024 · 3 comments
Open
4 tasks done

[tcgc] namespaces in TCGC #1604

iscai-msft opened this issue Sep 24, 2024 · 3 comments
Assignees
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@iscai-msft
Copy link
Contributor

Clear and concise description of the problem

As we start implementing "namespace is namespace" in our language emitters, TCGC plays an important role in helping emitters get the information they need to generate. At the same time, it is important that we are not breaking, both for ease of migration, and also because some languages (like javascript) don't really have a concept of "namespace" and won't be adopting this behavior the same way the other language emitters are.

As such, I propose a multi-part approach in getting TCGC to help with the "namespace is namespace" push.

  1. Ensure that the existing .namespace string on SdkClientTypes returns the correct namespace
  2. Add a .namespace string onto SdkModelType and SdkEnumType, so we can generate these models in the correct space.
  3. Add additional helper method getNamespaceToClients(sdkContext) that returns a mapping of namespaces to clients in those namespaces.
  4. Add additional helper method getNamespaceToModels(sdkContext) that will return a mapping of namespaces to models in those namespaces

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the TypeSpec repo
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@iscai-msft iscai-msft added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Sep 24, 2024
@iscai-msft iscai-msft self-assigned this Sep 24, 2024
@tadelesh
Copy link
Member

Another option is making SkdPackage to be hierarchy with namespace, and add a flag like flatten-namespace and default to true to prevent breaking change for some languages.

@chunyu3
Copy link
Member

chunyu3 commented Sep 25, 2024

How about the namespace defined in @client? As following, the client include more parts separated by ., and all the parts except the latest one will be the namespace of the client, will tcgc help to merge this to namespace of the client?

@client(
  {
    name: "SubNamespace.SecondClient",
    service: FirstTest.Service,
  }
)

@archerzz
Copy link
Member

For 3 & 4, what's the user scenario? There are basically 2 ways to provide the relationship between the namespaces and their belonging entities (clients, models, etc):

  • a hierarchy of SdkInputNameSpace with child properties representing clients, models, etc.
  • or a flat mapping like suggested on top

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

No branches or pull requests

4 participants