[Feature Request] Automatically Add using

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

Suppose I try to use StringBuilder in my application. The VS.Net Doesn't
recognize the class untill I first do a "using System.Globalization".

This is very inconvinient. When I type StringBuilder in my application,
why can't VS.net automatically add "using System.Globalization" to my code?

VS.Net should kind of know which class is in which namespace (atleast
for the ones which belong to .Net) and add the appropriate using line
itself.

regards,
Abhishek.
 
Hi,

Then what would happen if you use Timer in your application?
There is a Timer defined in System.Windows.Form , another in
System.Threading and other more in System.Timers

The IDE has no way to know which one you want to use.

Another possible problematic escenario, what if you define a StringBuild
class in your application, and you by mistake later mistype StringBuilder ,
this can get you to very subtle errors to find.

BTw, StringBuilder is in System.Text no in System.Globalization.

Cheers,
 
Then what would happen if you use Timer in your application?
There is a Timer defined in System.Windows.Form , another in
System.Threading and other more in System.Timers

The IDE has no way to know which one you want to use.

For classes with same name but appearing in two namespaces, we should
let the user specifiy it manually (the situation of today) because there
is no way for the IDE to know which one you want to use. [or a popup
asking which one you want to use... however personaly I find popups very
rude].

However, for unique name classes, the IDE should automatically add the
using clause without the user having to manually add it.
Another possible problematic escenario, what if you define a StringBuild
class in your application, and you by mistake later mistype StringBuilder ,
this can get you to very subtle errors to find.

If I have a class called StringBuild ... but I make a typo and use it as
StringBuilder, then StringBuilder will be used. The programmer must be
carefull in naming, and debugging their code. This is the same as when
you use wanted to use a class called Time and make a Typo of Timer.

The IDE should be dynamic, when I change the StringBuild to
StringBuilder then the automatically added namespace of StringBuild
should be removed and the namespace of StringBuilder should be added.
BTw, StringBuilder is in System.Text no in System.Globalization.
you're right. sorry for the typo... :-)

regards,
Abhishek.
 
Abhishek Srivastava said:
Hello All,

Suppose I try to use StringBuilder in my application. The VS.Net Doesn't
recognize the class untill I first do a "using System.Globalization".

This is very inconvinient. When I type StringBuilder in my application,
why can't VS.net automatically add "using System.Globalization" to my
code?

VS.Net should kind of know which class is in which namespace (atleast for
the ones which belong to .Net) and add the appropriate using line itself.

As with most IDE features, I think this would be nice in some situations,
but a problem in others. The only thing I'd like to see with it is an easy
key stroke for toggling it on and off, as I suspect it could be some trouble
when you are writing code that relies on classes you havn't written yet, ;).
With a keystroke or other easy way to switch (and an apparent icon or
whatnot that signifies the function is on), I think it could increase
productivity, especially for System.Text and the like, which probably should
be in the default set but isn't.
 
Back
Top