簡體   English   中英

Editorconfig indent C# 記錄屬性

[英]Editorconfig indent C# record properties

我正在嘗試使用 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; }
    }
}

這是我的編輯器配置文件

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見這里)——當時,C# 中甚至不存在record

嘗試更新版本: https://www.jetbrains.com/help/resharper/CleanupCode.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM