In some cases the control and candidate methods may not return the same types. In our all-to-overused permissions example, let's pretend UserPermissions.CheckUser(currentUser) returns a bool, but User.Can(currentUser, Permission.Read) returns a more complex object. In that case, we would have to set up the candidate as
(I realize this is a terrible example.) Although not a huge deal, it's more verbose than it needs to be. Users might also want to compare 2 different complex types which is difficult in the current setup.
I propose an interface similar to this:
public sealed class Experiment<TResult, KResult>
This allows the control and candidate to have different types if necessary. We can also overload New to allow only specifying a single parameter if both are the same:
public static Experiment<TResult, TResult> New<TResult>([NotNull]string name)
public static Experiment<TResult, KResult> New<TResult, KResult>([NotNull]string name)
In the case of specifying 2 different types the user will have to include a comparer, but I think the functionality outweighs that very slight negative.
In some cases the control and candidate methods may not return the same types. In our all-to-overused permissions example, let's pretend
UserPermissions.CheckUser(currentUser)
returns abool
, butUser.Can(currentUser, Permission.Read)
returns a more complex object. In that case, we would have to set up the candidate as(I realize this is a terrible example.) Although not a huge deal, it's more verbose than it needs to be. Users might also want to compare 2 different complex types which is difficult in the current setup.
I propose an interface similar to this:
This allows the control and candidate to have different types if necessary. We can also overload
New
to allow only specifying a single parameter if both are the same:In the case of specifying 2 different types the user will have to include a comparer, but I think the functionality outweighs that very slight negative.