Remora / Remora.Results

A simple, versatile algebraic data type for C#.
GNU Lesser General Public License v3.0
15 stars 5 forks source link

Analyzer for failing to use a Result #6

Open jcotton42 opened 2 years ago

jcotton42 commented 2 years ago

Given that results aren't "noisy" like exceptions it would be useful to get a warning/error if you fail to use one. As an example, the following code should result in some sort of warning:

// some code
MethodThatReturnsAResult();
// some more code

From here there's two ways I can see this going: you only need to read the Result at all to shut up the analyzer

// some code
var weNeveDoAnythingWithThis = MethodThatReturnsAResult();
// some more code

Or you actually have to do something with the variable it's assigned to, and to explicitly ignore it you would need to use a discard

// some code
_ = MethodThatReturnsAResult();
// some more code