Reputation: 4539
Is there a way to configure ReSharper to add using references to a file within the appropriate namespace?
Currently it adds them to the top of the file, which is fine, until you want multiple namespaces in the same file.
For example, I would like it to be like the following:
namespace A
{
using System;
// other classes
}
Upvotes: 4
Views: 2868
Reputation: 637
Just to bring an up to date answer here as I was wanting to do this but not having R# (ReSharper) installed...
Its now available from Visual Studio 2019 directly since the 16.1 Release.
I found this on developercommunity.visualstudio.com
The code style to include using directives inside or outside a namespace was added in Visual Studio 2019 update 16.1. You can now set your preference in Tools > Options > Text Editor > C# > Code Style or in an EditorConfig file and the IDE can apply it through messages, warnings, or errors depending on the severity you specify in the code style rule
Upvotes: 3
Reputation: 6920
Options > Code Editing > C# > Namespace Imports:
Insert using directives when necessary > Add using directive to the deepest scope.
Upvotes: 8