首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Editorconfig缩进C#记录属性

Editorconfig缩进C#记录属性
EN

Stack Overflow用户
提问于 2022-04-29 23:59:42
回答 1查看 68关注 0票数 0

我试图使用editorconfig +ReSharper/leanupcode.exe来格式化我的C#代码(使用这个酷酷的预承诺钩)

我遇到的问题是,清除代码拒绝缩进record中的属性。

代码语言:javascript
复制
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文件

代码语言:javascript
复制
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缩进这些记录属性吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-02 08:13:00

我只测试了你的设置在骑士和属性是突出显示,你想要。

提到的工具已经相当老了(v2019.3.1请看这里) --当时,C#中甚至不存在records。

尝试使用更新的版本:https://www.jetbrains.com/help/resharper/CleanupCode.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72064704

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档