简体   繁体   English

如何在格式化时自动移动命名空间内的 using 指令?

[英]How to automatically move the using directives inside the namespace on formatting?

Currently I have a.editorconfig in my VS setup which make the suggestion to move the using directives inside the namespace in C#.目前,我的 VS 设置中有一个 .editorconfig,它建议在 C# 的命名空间内移动 using 指令。 But sometimes it fails I don't know why.但有时它会失败,我不知道为什么。 Could be a bad setting in VS? VS中的设置可能不好? Although my main concern is that I want the using directives to automatically move inside the namespace when formatting.虽然我主要关心的是我希望 using 指令在格式化时自动移动到命名空间内。 Is this possible?这可能吗?

I'm using Microsoft Visual Studio Professional 2019 Version 16.9.0我正在使用 Microsoft Visual Studio Professional 2019 版本 16.9.0

I suppose you configured the csharp_using_directive_placement option.我想您配置了csharp_using_directive_placement选项。

There is currently a bug open on the github roslyn project close to this subject.目前在 github roslyn 项目中存在一个与此主题相关的错误。 The bug is about misplaced new using directive added by refactoring (not moving the existing one).该错误是关于通过重构添加的新using指令放错位置(不移动现有指令)。

You may open a feature request on the roslyn project.您可以在 roslyn 项目上打开功能请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM