It seems that if the first property is null, the serialized output starts with &.
#!/usr/bin/env dotnet run
#:package WebSerializer@1.3.0
using System.Runtime.Serialization;
using Cysharp.Web;
var req = new Request(sortBy: null, direction: SortDirection.Desc, currentPage: 3);
var q = WebSerializer.ToQueryString(req);
//await httpClient.GetAsync("/sort?"+ q);
Console.WriteLine("/sort?"+ q);
// expected: /sort?direction=Desc¤tPage=3
// actual: /sort?&direction=Desc¤tPage=3
public record Request(
[property: DataMember(Order = 0)] string? sortBy,
SortDirection direction,
int currentPage
);
public enum SortDirection
{
Default,
Asc,
Desc
}
It seems that if the first property is null, the serialized output starts with
&.