Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 166 forks source link

Missing API version in operation group client when there is scope on parent client #4973

Open Han-msft opened 1 month ago

Han-msft commented 1 month ago

When SDK language specified in scope of @client, generated operation group will miss API version. client.tsp

@client({
  name: "FaceServiceClient",
  service: Face,
}, "csharp,python")
@client({
  name: "administration.FaceServiceClient",
  service: Face,
}, "java")
namespace FaceServiceClient {
  @operationGroup
  @clientName("FaceListClientImpl", "csharp")
  interface FaceList {
...    
  }
...
}

Generated client

        internal FaceListClientImpl(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint)
        {
            ClientDiagnostics = clientDiagnostics;
            _pipeline = pipeline;
            _keyCredential = keyCredential;
            _tokenCredential = tokenCredential;
            _endpoint = endpoint;
        }

If there is no scope in parent client, operation group client will have api version on internal constructor. client.tsp

@client({
  name: "FaceServiceClient",
  service: Face,
})
namespace FaceServiceClient {
  @operationGroup
  interface FaceLists {
...
  }
...
}

Generated client

        internal FaceLists(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion)
        {
            ClientDiagnostics = clientDiagnostics;
            _pipeline = pipeline;
            _keyCredential = keyCredential;
            _tokenCredential = tokenCredential;
            _endpoint = endpoint;
            _apiVersion = apiVersion;
        }
chunyu3 commented 1 week ago

The TCGC miss the apiVersion client parameter. File issue https://github.com/Azure/typespec-azure/issues/1499 to track