我试图使用editorconfig +ReSharper/leanupcode.exe来格式化我的C#代码(使用这个酷酷的预承诺钩)
我遇到的问题是,清除代码拒绝缩进record中的属性。
namespace MyNameSpace
{
public record MyRecord
{
// I would like these to be indented
public int Property1 { get; init; }
public int Property2 { get; init; }
}
public class MyClass
{
public int Property1 { get; init; }
public int Property2 { get; init; }
}
}这是我的editorconfig文件
root = true
# top-most EditorConfig file
# Don't use tabs for indentation.
[*]
indent_style = space
# ReSharper properties
resharper_place_accessor_attribute_on_same_line = true
# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
csharp_indent_block_contents = true
csharp_max_line_length = 150有人知道我需要设置什么样的设置/规则才能使editorconfig/ReSharper缩进这些记录属性吗?
发布于 2022-05-02 08:13:00
我只测试了你的设置在骑士和属性是突出显示,你想要。
提到的工具已经相当老了(v2019.3.1,请看这里) --当时,C#中甚至不存在records。
尝试使用更新的版本:https://www.jetbrains.com/help/resharper/CleanupCode.html
https://stackoverflow.com/questions/72064704
复制相似问题