OneOf icon indicating copy to clipboard operation
OneOf copied to clipboard

Code analyzer to warn if OneOf<> not handled

Open gorillapower opened this issue 7 months ago • 0 comments

It would be really useful to have a code analyzer to display a warning/error for any unhandled instance of OneOf<>.

If a developer forgets to handle a OneOf<> result (besides using the Match or Switch methods) a warning/error would at compile time would prevent any potenial swallowed errors.

EG)

public OneOf<Success, Error> MyMethod()
{
    return new Error();
}

public IActionResult DoRequest()
{
   var result = MyMethod();
   //display compiler warning "Unhandled Result"
   
   return Ok();

}

gorillapower avatar Jun 27 '24 03:06 gorillapower