Editorconfig缩进c#记录属性



我正在尝试使用editorconfig + ReSharper/cleanupcode.exe来格式化我的c#代码(使用这个很酷的预提交钩子)

我遇到的问题是,cleanupcode拒绝缩进属性在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缩进这些记录属性吗?

我只测试了您在Rider中的设置,并且属性会按照您的要求突出显示。

上面提到的工具是相当老的(v2019.3.1,见这里)——在那个时候,record在c#中甚至不存在。

请使用新版本:https://www.jetbrains.com/help/resharper/CleanupCode.html

最新更新