I have the following overloads for the method Add:
public void Add<T>(string propertyName, object value) where T:MyBaseClass
public void Add(MyBaseClass entity, string propertyName)
public void Add(string name, DbType type, object value)
When I use intellisense, the generic type parameter T doesn't show up, so, if I use the first signature with the help of Intellisense, I write this:
and I get this error:
Argument type 'string' is not assignable to parameter type 'MyBaseClass'.
The error message is right: as I have not supplied the type parameter T, the code analyzer tries to match the second or thrid signature of the method and none of them matches. Naturally, if I supply the parameter type T like this:
the error disappears.
The problem is that Intellisense is very confusing as it never helps you determine that there's a missing type parameter. I think that, if Intellisense showed the parameter type T while showing the method overloads it would help solve the problem.
If I rename the method to have a different name, the behaviour improves, but it's still not satisfying. Intellisense keeps hiding the parameter type, so, if I try to write the method, when I have this selected on intellisense
params.AddT (string propertyname, object value):void
I'll write the opening parenthesis to choose this method signature and I'll get this disturbing sentence:
So I think the parameter type T should always be shown in the Intellisense pane, something like this:
params.AddT <T>(string propertyname, object value):void
params.AddT<T> (string propertyname, object value):void
Am I missing any settign that help me with this? Are you having the same problem?