"Move To Another File" 后大括号布局错误
Wrong Braces Layout after "Move To Another File"
使用重构工具时Move To Another File
或Move Types Into Matching Files
Resharper 在命名空间后使用了错误的换行符样式。如果我用这些工具重构 class 它会生成这样的代码,尽管我的 Braces Layout
配置为 At next line (BSD style)
namespace My.Namespace { // <- This brace should be on the next line
public class MyClass
{
public MyClass()
{
// ...
}
}
}
当我之后进行代码清理时,代码格式正确:
namespace My.Namespace
{
public class MyClass
{
public MyClass()
{
// ...
}
}
}
有人知道是什么导致了这种行为吗?为什么命名空间的大括号之前没有换行符?
我正在使用 ReSharper 2018.3.1
有大括号设置
ReSharper > Options > Code Editing > C# > Formatting Style > Braces Layout
你能检查 Type and namespace declaration
设置是否设置为 At Next Line (BSD Style)
我正在使用 ReSharper 2018.2.3,一切正常。
更新
我将我的 ReSharper 更新到 18.3.1,但仍然一切正常。您还可以检查 Tools > Options > Text Editor > C# > Code Style > Formatting > New Lines > New line options for braces
.
上大括号的 VS 默认选项吗
恐怕 ReSharper 无法覆盖所有 Visual Stuido 行为。为了避免这种情况,只需关闭所有“自动
格式化 ...' Tools > Options > Text Editor > C# > Formatting > General
上的选项,这样它就不会妨碍。
这解决了我的问题:
ReSharper > Options > Code Editing > c# > Formatting Style > Braces Layout
设置 Empty braces formatting
已开启 Together on the same line
。所以我将其更改为 On different lines
。进行此更改后,它起作用了。
使用重构工具时Move To Another File
或Move Types Into Matching Files
Resharper 在命名空间后使用了错误的换行符样式。如果我用这些工具重构 class 它会生成这样的代码,尽管我的 Braces Layout
配置为 At next line (BSD style)
namespace My.Namespace { // <- This brace should be on the next line
public class MyClass
{
public MyClass()
{
// ...
}
}
}
当我之后进行代码清理时,代码格式正确:
namespace My.Namespace
{
public class MyClass
{
public MyClass()
{
// ...
}
}
}
有人知道是什么导致了这种行为吗?为什么命名空间的大括号之前没有换行符?
我正在使用 ReSharper 2018.3.1
有大括号设置
ReSharper > Options > Code Editing > C# > Formatting Style > Braces Layout
你能检查 Type and namespace declaration
设置是否设置为 At Next Line (BSD Style)
我正在使用 ReSharper 2018.2.3,一切正常。
更新
我将我的 ReSharper 更新到 18.3.1,但仍然一切正常。您还可以检查 Tools > Options > Text Editor > C# > Code Style > Formatting > New Lines > New line options for braces
.
恐怕 ReSharper 无法覆盖所有 Visual Stuido 行为。为了避免这种情况,只需关闭所有“自动
格式化 ...' Tools > Options > Text Editor > C# > Formatting > General
上的选项,这样它就不会妨碍。
这解决了我的问题:
ReSharper > Options > Code Editing > c# > Formatting Style > Braces Layout
设置 Empty braces formatting
已开启 Together on the same line
。所以我将其更改为 On different lines
。进行此更改后,它起作用了。