Parameter type T in generic methods don't show up in Intellisense

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:

params.Add("MyPropertyName", myPropertyValue);

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:


params.Add<MyPropertyClass>("MyPropertyName", myPropertyValue);

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:

params.AddT<(>()

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

or this

params.AddT<T> (string propertyname, object value):void


Am I missing any settign that help me with this? Are you having the same problem?

1 comment

Hello Jorge,

This is certainly a usability problem that should be addressed. Here's an
issue id from our tracker for the reference: http://youtrack.jetbrains.net/issue/RSRP-233958.
Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

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:

params.Add("MyPropertyName", myPropertyValue);

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:

params.Add<MyPropertyClass>("MyPropertyName", myPropertyValue);

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:

params.AddT<(>()

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

or this

params.AddT<T> (string propertyname, object value):void



0

Please sign in to leave a comment.