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

Open
wants to merge 39 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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

I see - I removed the clientNamespace part.

@ArcturusZhang
Copy link
Member Author

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

using Client.Naming.Models;
using NUnit.Framework;
using ClientModel = Client.Naming.Models.ClientModel;
// using System.Threading.Tasks;
Copy link
Member Author

Choose a reason for hiding this comment

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

these test cases are removed because of this issue: #5653

@ArcturusZhang ArcturusZhang marked this pull request as ready for review January 17, 2025 08:43
@@ -50,6 +50,12 @@ const $lib = createTypeSpecLibrary({
default: paramMessage`${"message"}`,
},
},
"bad-namespace": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "client-namespace-conflict"?

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
4 participants