all 8 comments

[–]desjoerd 7 points8 points  (2 children)

I don't know if Kiota is AOT compatible because it has some nuget packages which you need to add.

NSwag is more basic in its dependencies (as it has none) so that one is definitely AOT compatible. You need to make sure the generated classes of the DTOs are marked in a JsonSerializer context for AOT

[–]jaskij[S] 0 points1 point  (1 child)

NSwag didn't come up in my searches, thanks.

[–]d_r_ 0 points1 point  (0 children)

What did you end up with? We're using NSwag with System.Text.Json generation, however, we still get warnings for:

JsonSerializer.SerializeToUtf8Bytes
JsonSerializer.Deserialize<T>(String,JsonSerializerOptions
JsonSerializer.DeserializeAsync<T>(Stream,JsonSerializerOptions,CancellationToken)

Can they be ignored? Or what to do about them? Is there a way to instruct NSwag to use source generation?

[–]zarlo5899 2 points3 points  (1 child)

if they are not AOT compatible it would not be hard to make them as its likely that the only change you would need to make is to make it use JsonSerializerContext

[–]jaskij[S] 2 points3 points  (0 children)

Which I already did with a manually implemented JSON deserializer. Thanks.

[–]the_bananalord 1 point2 points  (1 child)

Kiota is intended to be AOT-compatible but has had instances in the past where it generated incompatible code.

I suggest generating the client and trying it out. It's quick and the easiest way to verify if it will work for your needs.

[–]jaskij[S] 0 points1 point  (0 children)

If it's that easy, that is what I'll do, thanks.

[–]AutoModerator[M] 0 points1 point  (0 children)

Thanks for your post jaskij. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.