Skip to content

Moving extension methods onto IResult (to enable covariance) #530

Open
@redx177

Description

@redx177

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions