Skip to content

Generated Back Compat Service Methods Do Not Compile If Params Have Reserved Names #10641

Description

As part of 72a95c2, back compat support was added for service operations. There two bugs that were found as part of Azure/azure-sdk-for-net#59156

  • If the previous version of the method had reserved param names select, top, skip, etc we need to correctly generate the named argument.
    In example:
/// <summary> Lists all indexes available for a search service. </summary>
/// <param name="select"> Selects which top-level properties to retrieve. Specified as a comma-separated list of JSON property names, or '*' for all properties. The default is all properties. </param>
/// <param name="cancellationToken"> The cancellation token that can be used to cancel the operation. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual AsyncPageable<SearchIndexResponse> GetIndexesWithSelectedPropertiesAsync(IEnumerable<string> @select, CancellationToken cancellationToken)
{
    return this.GetIndexesWithSelectedPropertiesAsync(select: default, top: default, skip: default, count: default, cancellationToken: cancellationToken);
}```

instead of:

```csharp
/// <summary> Lists all indexes available for a search service. </summary>
/// <param name="select"> Selects which top-level properties to retrieve. Specified as a comma-separated list of JSON property names, or '*' for all properties. The default is all properties. </param>
/// <param name="cancellationToken"> The cancellation token that can be used to cancel the operation. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual AsyncPageable<SearchIndexResponse> GetIndexesWithSelectedPropertiesAsync(IEnumerable<string> @select, CancellationToken cancellationToken)
{
    return this.GetIndexesWithSelectedPropertiesAsync($select: default, $top: default, $skip: default, $count: default, cancellationToken: cancellationToken);
}
  • We should not generate methods that violate Client method should have an optional CancellationToken called cancellationToken (both name and it being optional matters) or a RequestContext called context as the last parameter.. If the previous method had a cancellationToken param, it should be optional.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingemitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions