I've searched for this and found this: How To Detect If Type is Another Generic Type
The problem with this solution is that it expects the implementation to have the same type parameters. What I want is to see if a class implements an interface with any type parameter.
Example:
public interface IMapper<in TSource, out TDestination>
{ ... }
public class StringMapper : IMapper<string, StringBuilder>
{ ... }
Console.WriteLine(typeof(IMapper<,>).IsAssignableFrom(typeof(StringMapper)));
I want this to write true, but it writes false. How can I check if a class implements an interface with generic parameters?