autorest.csharp: Include both protocol method and grow-up method will break user

Describe the issue or request We are considering adding both protocol method and grow-up method into DPG client. Eg.,

// protocol method
public virtual async Task<Response> GetModelAsync(string mode, RequestContext context = null); 
// grow-up method.
public virtual async Task<Response<Model>> GetModelAsync(string mode, CancellationToken cancellationToken = default); 

That will break if user calls GetModelAsync(“mode”) without RequestContext and CancellationToken.

This issue does not exist in post. Eg.,

// protocol method
public virtual async Task<Response> PostModelAsync(RequestContent requestContent, RequestContext context = null); 
// grow-up method.
public virtual async Task<Response<Model>> PostModelAsync(Input mode, CancellationToken cancellationToken = default); 

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

My reasoning is the following: we want 4 things:

  1. Users should be able to cancel server calls, if they want to, thus we need to have at least one overload taking CT.
  2. We want to avoid having to mangle method names, i.e. avoid the “Value” suffix.
  3. Shorter parameters lists are simpler than longer ones, thus there rarely used parameter should not appear in helper overloads (this is generic .NET guideline/design-philosophy).
  4. Cast operators are not visible in intellisense, and so relying on them has negative UX impact.

isn’t making the model castable from Response in the https://github.com/Azure/autorest.csharp/pull/3 bucket that we will address after we have completed https://github.com/Azure/autorest.csharp/pull/4, e.g. the full grow-up story?

The way I think about it is that we postponed the official support, exploring all corner cases (e.g. casing untyped LROs to typed LROs), etc. But I think it would be totally reasonable to provide informal guidance to teams who run into simple cases like this one, unless we have a concrete concern about the informal guidance.