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

Implement tsp namespace for http-client-csharp #5443

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

ArcturusZhang
Copy link
Member

@ArcturusZhang ArcturusZhang commented Dec 25, 2024

Fixes #5442
Fixes #5471

This PR contains the following:

  1. now we honor the namespace defined in typespec for both model and clients (short for "namespace is namespace" feature)
  2. removes the namespace configuration from the emitter because we no longer need it.
  3. removes the model-namespace configuration from the emitter because we no longer need it.
  4. reports diagnostic when there are conflicts between namespace segments and subclient names.

Because this change changes the namespace of literally everything, there are quite a few file changed. Majority of them are the generated files changed for the namespace.

For 2 and 3, since it impacts azure generator, I would like to do them in a standalone PR.

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Dec 25, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 25, 2024

API change check

APIView has identified API level changes in this PR and created following API reviews.

Microsoft.Generator.CSharp.Input
@typespec/http-client-csharp
Microsoft.Generator.CSharp
Microsoft.Generator.CSharp.ClientModel

// this segment is bad
badNamespaceSegments.add(lastSegment);

Logger.getInstance().warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a specific diagnostic for this as we have an open issue to remove the generic one. This allows customers to opt into and out of warnings they care about.

Copy link
Member Author

@ArcturusZhang ArcturusZhang Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there is a plan about this actually. Good to see we already have an issue to track this.
In general, we need to do some rearrangements on our existing diagnostics, errors, etc to make them more meaningful.

I will create a new diagnostic for it for now. Maybe we need to review it later

badNamespaceSegments.add(lastSegment);

Logger.getInstance().warn(
`bad namespace ${client.clientNamespace} for client ${clientName}, please use @clientNamespace to specify a different namespace or @clientName to specify a different name for the client`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should promote @clientNamespace as this introduces multiple ways to rename things. @clientName can rename any object type.

See this issue for additional comments on this topic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean we should put @clientName first here in the message?

@ArcturusZhang
Copy link
Member Author

need to add the extension namespace of the pipeline when invoking the extension method from the helpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
3 participants