Automatic output of type arguments only works if no common arguments are specified in the method call. Ie this:
myDto.ShouldHave<, RequiredAttribute, >(x => x.Id);
Invalid syntax. You can either "all or nothing."
, T TT, , TV, - . , :
public static void ShouldHave<T, TT>(this T obj,
Expression<Func<T, TT>> exp,
Type attribute) {...}
(, ShouldHave).
:
MyDto myDto = new MyDto();
myDto.ShouldHave(x => x.Id, typeof(RequiredAttribute));