Covariance is only working with interfaces. Meaning something like this is possible:
public interface IVehicle { }
public class Car : IVehicle { }
public class Bus : IVehicle { }
IResult<IVehicle> carResult1 = Result.Success(new Car());
This on the other hand is not possible:
Result<IVehicle> carResult2 = Result.Success(new Car());
The solution seams simple, just go with IResult rather than Result.
But all the extension methods (those) are on Result, and not on IResult.
Is there a possibility to put all extension methods onto IResult rather than Result?
The "creation" methods (those) can stay on Result, but they return an IResult.
I guess when the extension methods are moved to IResult, we break compatibility...
If the extension methods are copied to IResult, the codebase gets much bigger...
Covariance is only working with interfaces. Meaning something like this is possible:
This on the other hand is not possible:
The solution seams simple, just go with
IResultrather thanResult.But all the extension methods (those) are on
Result, and not onIResult.Is there a possibility to put all extension methods onto
IResultrather thanResult?The "creation" methods (those) can stay on
Result, but they return anIResult.I guess when the extension methods are moved to
IResult, we break compatibility...If the extension methods are copied to
IResult, the codebase gets much bigger...