refit icon indicating copy to clipboard operation
refit copied to clipboard

question: does Refit support C# 9 record?

Open roubachof opened this issue 2 years ago • 5 comments

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 ?

roubachof avatar Jul 29 '21 10:07 roubachof

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

laurentksh avatar Sep 13 '21 08:09 laurentksh

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

Toloymak avatar Mar 22 '22 14:03 Toloymak

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

vmachacek avatar Aug 06 '22 23:08 vmachacek

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

starushykart avatar Jan 11 '24 13:01 starushykart

JsonProperty doesn't work with records also

djekmusic avatar Jan 31 '24 13:01 djekmusic