GenerateAspNetCoreClient icon indicating copy to clipboard operation
GenerateAspNetCoreClient copied to clipboard

Nullability operator in contracts implementation

Open valentasm1 opened this issue 3 years ago • 4 comments

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);

valentasm1 avatar Nov 22 '22 08:11 valentasm1

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?

Dreamescaper avatar Nov 22 '22 10:11 Dreamescaper

Nothing serious. It is just compiler warnings.

valentasm1 avatar Nov 22 '22 10:11 valentasm1

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

Dreamescaper avatar Nov 22 '22 10:11 Dreamescaper

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

valentasm1 avatar Nov 22 '22 11:11 valentasm1