OneOf
OneOf copied to clipboard
Code analyzer to warn if OneOf<> not handled
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();
}