'Editorconfig indent C# record properties
I am trying to use editorconfig + ReSharper/cleanupcode.exe to format my C# code (using this cool precommit hook)
The problem I am having is that cleanupcode refuses to indent properties in a 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; }
}
}
Here is my editorconfig file
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
Does anyone know what setting/rule I need to set to make editorconfig/ReSharper indent these record properties?
Solution 1:[1]
I only tested your settings in Rider and the properties are getting highlighted as you'd like to.
The mentioned tool is pretty old (v2019.3.1, see here) - at that time, records didn't even exist in C#.
Try it with a newer version: https://www.jetbrains.com/help/resharper/CleanupCode.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mu88 |
