Automatic imports statements

Hi
Is there any way to have R# (or VS 2008) automatically import my using
statements at the beginning of the file?

Thanks
Jeremy


10 comments

Anyone??

"Jeremy Holt" <no_reply@jetbrains.com> wrote in message
news:gcu84m$2ii$1@is.intellij.net...

Hi
Is there any way to have R# (or VS 2008) automatically import my using
statements at the beginning of the file?

>

Thanks
Jeremy

>
>

0

what do you mean? By default, put directive to top sectiopn, and sort it.

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Jeremy Holt" <no_reply@jetbrains.com> wrote in message
news:gdiuid$646$1@is.intellij.net...

Anyone??

>

"Jeremy Holt" <no_reply@jetbrains.com> wrote in message
news:gcu84m$2ii$1@is.intellij.net...

>> Hi
>> Is there any way to have R# (or VS 2008) automatically import my using
>> statements at the beginning of the file?
>>
>> Thanks
>> Jeremy
>>
>>
>>


0

I want the same thing, instead of having to press Alt+Enter to add the using at top (when you are using a type but missing the using statement) and there is only one suggestion.

eg:

I'm typing

// BEGIN CODE
public class Test
{
public void TestMethod()
{
DateTime// At this point I want resharper to automaticly add "using System;" at the beginning of the file
// END CODE

0

I see. We are going to discuss this issue inside our team, but personally I
do not think this is a good idea, since there may be other user intentions

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"XIU" <xiu@shoeke.com> wrote in message
news:22365493.4961224582500755.JavaMail.jive@app4.labs.intellij.net...
>I want the same thing, instead of having to press Alt+Enter to add the
>using at top (when you are using a type but missing the using statement)
>and there is only one suggestion.
>

eg:

>

I'm typing

>

// BEGIN CODE
public class Test
{
public void TestMethod()
{
DateTime// At this point I want resharper to automaticly add "using
System;" at the beginning of the file
// END CODE



0

Directly after DateTime might be a bit too fast so maybe only when a type is chosen? So not for all cases it handles now (extension methods, static methods/properties)

DateTime now = // can't really be something else
result = DateTime. // it could be a DateTime property so don't do it here
etc

0

Hello XIU,

Why not use Import Symbol completion? See ReSharper | Code | Complete Code
menu for shortcut.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


X> Directly after DateTime might be a bit too fast so maybe only when a
X> type is chosen? So not for all cases it handles now (extension
X> methods, static methods/properties)
X>
X> DateTime now = // can't really be something else
X> result = DateTime. // it could be a DateTime property so don't do
X> it here
X> etc


0

Hello XIU,

I don't quite understand why typing "DateTime" with automatic import after
space(?) and may be some other symbols like dot is any better than typing
"DT" and using Import Symbol completion :)

Next, if you like many other, use types from "System" namespace a lot and
ReSharper removes them as redundant during code cleanup, you can configure
them as "should always be there" or "should not be removed" in the Options
/ Languages / C# / Namespace Imports.

Finally, if you want types to be autoimported for any other reason (i.e.
not common types and you don't like "Import Type" with Camel Humps for some
reason), you may want to explain the benefit (saving one Alt-Enter is sure
not enough to justify the potential harm) and probably think about dealing
with various ambiguites that can arise. Just asking for "I want ReSharper
to write all the code for me" is not something that is implementatble :)

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


X> That one, but automaticly :P
X>


0

All I wanted to dowas that when creating a new class I would get the
following at the top of my new file.
using System;
using System.Linq;
using System.Collections.Generic;
etc

I actually realized the easiest way to this was to create a File Template -
problem solved.

Thanks



"Ilya Ryzhenkov" <orangy@jetbrains.com> wrote in message
news:76a2bd0b1643ae8cb02b615548f56@news.intellij.net...

Hello XIU,

>

I don't quite understand why typing "DateTime" with automatic import after
space(?) and may be some other symbols like dot is any better than typing
"DT" and using Import Symbol completion :)

>

Next, if you like many other, use types from "System" namespace a lot and
ReSharper removes them as redundant during code cleanup, you can configure
them as "should always be there" or "should not be removed" in the Options
/ Languages / C# / Namespace Imports.
Finally, if you want types to be autoimported for any other reason (i.e.
not common types and you don't like "Import Type" with Camel Humps for
some reason), you may want to explain the benefit (saving one Alt-Enter is
sure not enough to justify the potential harm) and probably think about
dealing with various ambiguites that can arise. Just asking for "I want
ReSharper to write all the code for me" is not something that is
implementatble :)
Sincerely,
Ilya Ryzhenkov

>

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>
>

X> That one, but automaticly :P
X>

0

Good point, I've always been using CtrlSpace and CtrlShiftSpace but never ShiftAltSpace and that really is exactly what I'm looking for :D the simplicity of CtrlT but with direct using adding.

Thanks for your help Ilya, this is all that I needed :)

0

Please sign in to leave a comment.