You would need to do:
typeof(SampleClassToTest<>).MakeGenericType(propertyType)
.GetMethod("SomeMethod", new Type[] {typeof(string)})
.Invoke(null, new object[] {"some parameter"});
Ugly.
If it can at all be helped, I would advise offering a non-generic API that accepts a Type
instance; the nice thing here is that a generic API can call into a non-generic API trivially by using typeof(T)
.