RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.72k stars 1.29k forks source link

Fix: C# Code Generation generates method with return default(void) #4826

Open nzeemin opened 6 months ago

nzeemin commented 6 months ago

This PR is made to avoid generation of C# code like this one (which leads to compilation error of course):

                        if (status_ == 204)
                        {
                            return default(void);
                        }

See also issues #3912, #3996.

fairking commented 1 month ago

The example bellow:

if (status_ == 204)
{
    return default(void);
}

should be

if (status_ == 204)
{
    return; // or return default;
}

But the question is what should we do with 200? I assume having "no result or default" is wrong.