1

I just scaffolded a project using Template Studio WinUI v5.3 and when I press Ctrl K D to format document, the getter and setter is placed on new lines.

current.cs

public class MyClass { public string MyProp { get; set; } } 

I want:

public class MyClass { public string MyProp { get; set; } } 

The readability is bad for a class with many properties. I searched a lot through Visual Studio and I still can't find the solution. The cause I suppose its related to a new C# version. My other projects use the same Visual Studio settings, but this formatting does not apply to them.
Do you know where can I find the setting for this problem?

Problem I write a prop like this public int MyProperty { get; set; }, then after I press Ctrl K D it moves them on multiline format.

1

1 Answer 1

4

You can set this in your .editorconfig:

[*.cs] csharp_preserve_single_line_blocks = true 

Or you can set it directly in VS: Tools > Options > Text Editor > C# > Code Style > Formatting > Wrapping and check "Leave block on single line".

Image of the above setting

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.