Skip to content

Commit

Permalink
datasets: error handling - multiple (ambiguous) interface implementat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
exyi committed Apr 27, 2024
1 parent 882b6e7 commit 24fc658
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,15 @@ private static Type GetOptionsConcreteType<TDataSetInterface>(Type dataSetConcre

var interfaces = dataSetConcreteType.GetInterfaces()
.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == genericInterface)
.Distinct()
.ToList();
if (interfaces.Count < 1)
{
throw new ArgumentException($"The {dataSetConcreteType} doesn't implement {genericInterface.Name}<TOptions>.");
}
else if (interfaces.Count > 1)
{
throw new ArgumentException($"The {dataSetConcreteType} implements multiple interfaces where {genericInterface.Name}<TOptions>. Only one implementation is allowed.");
throw new ArgumentException($"The {dataSetConcreteType} implements multiple interfaces where {genericInterface.Name}<TOptions> ({interfaces.Select(i => i.ToCode()).StringJoin(", ")}). Only one implementation is allowed.");
}

var pagingOptionsConcreteType = interfaces[0].GetGenericArguments()[0];
Expand Down

0 comments on commit 24fc658

Please sign in to comment.