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

[http-client-csharp] CSharp Emitter should find a better way to handle unsupported authentication #5355

Open
3 tasks done
Tracked by #5207
lirenhe opened this issue Dec 12, 2024 · 2 comments
Open
3 tasks done
Tracked by #5207
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Comments

@lirenhe
Copy link
Member

lirenhe commented Dec 12, 2024

Clear and concise description of the problem

Description of the problem:

Below is the TypeSpec that triggers this feature ask:
https://github.com/allenjzhang/typespec-e2e-demo/blob/main/todoApp/spec/main.tsp

@service({ title: "Todo App", }) @useAuth(BearerAuth | ApiKeyAuth<ApiKeyLocation.cookie, "session-id">)
@useAuth(NoAuth)

Generated code today:
https://github.com/allenjzhang/typespec-e2e-demo/blob/main/todoApp/clients/dotnet/src/Generated/TodoItems.cs

Expected behavior:

The general ask for all languages is to ignore those authentication and don't crash the codeGen.

There are some additional ask from .NET team and the below 2 issues contains the discussion of the expected behavior:
#5301
#5302

workstream this request is associated with

This is related to the TypeSpec E2E scenario and the experience would be integrated into vscode extension.

stakeholders

@lmazuel / @lirenhe

priority and timeline.

We need the E2E ready before end of Jan. For the project of todoApp, the ETA is Jan. 15th
Please refer: https://github.com/allenjzhang/typespec-e2e-demo/blob/main/1.0-E2E-status.md#client-generation

Close Azure/autorest.csharp#5185 as all dotnet items are tracked in this repo.

cc @jsquire

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@m-nash
Copy link
Member

m-nash commented Jan 13, 2025

We want to throw a warn diagnostic if the spec defines an auth that we don't support. We should still emit the remaining authentications that we do support.

If the spec only specifies unsupported authentications we should throw an additional warn diagnostic indicating that custom constructor is needed. The client should be created with no public constructor.

@ArcturusZhang
Copy link
Member

ArcturusZhang commented Jan 21, 2025

So @m-nash the report diagnostic on unsupported auth is done in this PR already, maybe we could close this issue and mark it as done.
In that PR, we have a big switch to convert the auth information from TCGC into ours, and in those branches we do not know what to convert to, a warning diagnostic is reported and undefined is returned which means we ignored those part that we do not support.
what do you think?

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
Development

No branches or pull requests

3 participants