Dreamescaper / GenerateAspNetCoreClient

DotNet tool to generate HTTP client classes from ASP.NET Core api controllers.
MIT License
63 stars 5 forks source link

Nullability operator in contracts implementation #14

Open valentasm1 opened 1 year ago

valentasm1 commented 1 year ago

Now i get

[Get("/some-api")]
Task<ListResponse> GetSome([AliasAs("page_number")] int? pagenumber = null, [AliasAs("date_types")] DateType[] dateTypes = null, [AliasAs("q")] string query = null);

It should add nullability operator ? on string and array too. It should work only on query params since they are optional. It should be

[Get("/some-api")]
Task<ListResponse> GetSome([AliasAs("page_number")] int? pagenumber = null, [AliasAs("date_types")] DateType[]? dateTypes = null, [AliasAs("q")] string? query = null);
Dreamescaper commented 1 year ago

Yeah, it doesn't support NullableReferenceTypes as for now. I'm wondering though - what issues does is cause? I don't think it causes any warnings due to <auto-generated /> tag, right?

valentasm1 commented 1 year ago

Nothing serious. It is just compiler warnings.

Dreamescaper commented 1 year ago

But where? Would have expected all compiler warnings to be disabled because of <auto-generated /> tag...

valentasm1 commented 1 year ago

I didnt knew it. Nice. It dont show warning in contract file. When i need to mock it for test, so it implements it without operator like this "string query = null". Workaround would be add exceptions for compiler warning, add ? manually. image