Skip to content

Compiler errors in C# client generated code when request has a List<T> as path parameter #4672

@fretje

Description

@fretje

I have a request that takes List<Guid> as a path parameter.

And there's code in the generated client that doesn't compile.

This is the signature of the generated client method:

public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<string>> GetSomethingAsync(System.Collections.Generic.IEnumerable<System.Guid> input)

This is the piece of code that doesn't compile (it's the piece that builds the input parameter for the url):

for (var i = 0; i < input.Length; i++)
{
    if (i > 0) urlBuilder_.Append(',');
    urlBuilder_.Append(ConvertToString(input[i], System.Globalization.CultureInfo.InvariantCulture));
}

The compiler errors are:

1>error CS1061: 'IEnumerable<Guid>' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'IEnumerable<Guid>' could be found (are you missing a using directive or an assembly reference?)
1>error CS0021: Cannot apply indexing with [] to an expression of type 'IEnumerable<Guid>'

This used to work fine in preview10, but doesn't anymore in the released v14.

For reference, this is the working generated code that was in preview10:

urlBuilder_.Append(System.Uri.EscapeDataString(string.Join(",", System.Linq.Enumerable.Select(input, s_ => ConvertToString(s_, System.Globalization.CultureInfo.InvariantCulture)))));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions