Proposal: Add a `TreatAsString` field to `QueryAttribute` by mark-pro · Pull Request #1943 · reactiveui/refit

@mark-pro

The proposal arises from the need to pass custom types or structs which might represent types with rules and conversions.

For example:

```csharp
record readonly struct ZipCode(ushort ZipCode) {
    public override string ToString() =>
        ZipCode.ToString();
}
```

To solve the problem the proposal seeks to add a field to the QueryAttribute called `TreatAsString`.

The new field is used when the query string is created and simply calls the `ToString()` function on a type.

There is a workaround that is not documented. The current workaround is to implement `IFormattable` on the type, which feels redundant if `ToString()` is already implemented on a custom type.

@mark-pro

@mark-pro

@mark-pro

@mark-pro

@mark-pro

ChrisPulman

@github-actions github-actions bot locked as resolved and limited conversation to collaborators

Jul 26, 2025