reactiveui / refit

The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
https://reactiveui.github.io/refit/
MIT License
8.59k stars 747 forks source link

question: does Refit support C# 9 record? #1208

Open roubachof opened 3 years ago

roubachof commented 3 years ago

C#9 records are finally the immutable type that we needed in C#. Since it's syntax is game changing, does refit supports serializing/deserializing such objects ?

laurentksh commented 3 years ago

I think they're already supported as, from my understanding, records are classes under the hood.

Toloymak commented 2 years ago

I use records as an input model and as a result model. It works fine :)

vmachacek commented 2 years ago

Does it work with [AliasAs] attribute? I had some issued with it when used like this:

public record AuthRequest([AliasAs("grant_type")] string GrantType,
    [AliasAs("scope")] string Scope,
    [AliasAs("client_id")] string ClientId,
    [AliasAs("client_secret")] string ClientSecret);

In this case the [AliasAs] is not reflected and the content looks like this

GrantType=client_credentials&Scope=read%3Aall&ClientId=foobar&ClientSecret=foobar

but should look like

grant_type=client_credentials&scope=read%3Aall&client_id=foobar&client_secret=foobar

starushykart commented 9 months ago

Hi! I have the same issue. [AliasAs] does not work with records and their primary c-tors

djekmusic commented 8 months ago

JsonProperty doesn't work with records also