ardalis / Result

A result abstraction that can be mapped to HTTP response codes if needed.
MIT License
866 stars 107 forks source link

MinimalApiResultExtensions.ToMinimalApiResult is missing case for ResultStatus.NoContent #191

Closed inghamc-csu closed 4 months ago

inghamc-csu commented 4 months ago

Tried to convert the Ardalis.Result return from my MediatR command to Microsoft.AspNetCore.Http.IResult using the ToMinimalApiResult() extension, and got a 500 from a thrown System.NotSupportedException when my Result value was Result.NoContent()

Assert.Fail(): Unhandled ResultStatus NoContent in MinimalApiResultExtensions.ToMinimalApiResult: System.NotSupportedException: Result NoContent conversion is not supported.
   at Ardalis.Result.AspNetCore.ResultExtensions.ToMinimalApiResult(IResult result) in /Users/inghamc/git/ardalis/inghamc.Result/src/Ardalis.Result.AspNetCore/MinimalApiResultExtensions.cs:line 48
   at Ardalis.Result.AspNetCore.ResultExtensions.ToMinimalApiResult(Result result) in /Users/inghamc/git/ardalis/inghamc.Result/src/Ardalis.Result.AspNetCore/MinimalApiResultExtensions.cs:line 32

I've added the missing case for NoContent and an xUnit test in a tests/Ardalis.Result.AspNetCore.UnitTests/MinimalApiResultExtensionsCoverage.cs that I'll include in a PR

ardalis commented 4 months ago

Sounds good thanks!

inghamc commented 2 months ago

Hi, any ETA on a release that would contain this fix? Thanks!

ardalis commented 2 months ago

Probably next week; out of office this week

inghamc commented 1 month ago

Pretty please on the release request 🥺