How to prevent ReSharper from shortening namespaces when adding using directives?
Asked Answered
H

1

12

When I use ReSharper to add a using directive (using Alt+Enter) it removes "unnecessary" parts of the namespace. I prefer using the full namespace which is also the behavior of Visual Studio.

Example:

namespace MyCompany.MyTool.Data
{
    // This is what ReSharper gives me:
    using Core;

    // This is what I want:
    using MyCompany.MyTool.Core;

    // ...
}

Which setting do I have to change in ReSharper 4.5 so it uses the full namespace?

Hackamore answered 26/12, 2009 at 22:9 Comment(2)
Which settings have you tried modifying?Lyon
@No Refunds No Returns: Pretty much every setting on the "Namespace Imports" pane.Hackamore
D
10

I don't have ReSharper 4.5 installed at the moment, but in 5.0 there's an option at the Namespace Imports pane called Prefer fully qualified using name at nested scope. It might be the one you're looking for.

Darleen answered 27/12, 2009 at 5:45 Comment(2)
This option seems not to be present in 4.5.Hackamore
I've got Resharper 2022.2 and had the same questions. Looks like this option has been moved to a different place. On the left choose Code Editing | C# | Syntax Style and on the right pane choose "Reference qualification and 'using' directives" and check "Prefer fully qualified using name at nested scope". You may also check "Add 'using' directive to the deepest scope" if you typically put your using statements inside namespace.Accentor

© 2022 - 2024 — McMap. All rights reserved.