json-api-dotnet/JsonApiDotNetCore

Incorrect separator in SparseFieldSetExpression.ToFullString

Closed this issue · 0 comments

In SparseFieldSetExpression.cs:

public override string ToString()
{
    return string.Join(",", Fields.Select(field => field.PublicName).OrderBy(name => name));
}

public override string ToFullString()
{
    return string.Join(".", Fields.Select(field => $"{field.Type.PublicName}:{field.PublicName}").OrderBy(name => name));
}

ToFullString incorrectly joins the fields in the set with a .; it should use a , instead.

Furthermore, we could use the overload of string.Join that takes a char as the separator, instead of string. There are additional places in the codebase where this optimization can be applied.