Is there way to define required class members order in the .editorconfig file?
Asked Answered
P

2

8

I use .editorconfig file to define code style rules in my .Net 5 solution. Is it possible to define required class members order in the .editorconfig? For example, public members should appear before private, non-static members should appear before static and methods before properties.

Peek answered 22/2, 2021 at 13:6 Comment(0)
U
3

You cannot define order of members in class using editorconfig, but you can write custom analyzer using Roslyn or use CodeMaid extensions for VS2019, not sure about VSCode extensions enter image description here

Ungulate answered 22/2, 2021 at 14:11 Comment(0)
S
2

I understand that this doesn't directly answer your question since you requested the ability to configure this in .editorconfig, but you could consider using StyleCop Analyzers, specifically Rule SA1202.

Sadly, it appears that this very helpful library has gone a little stale, with no official release in almost 3 years, as of the time of writing. I would love to see its capabilities merged into .NET Roslyn analyzers, with full .editorconfig support for configuring rules.

Stalwart answered 20/1, 2022 at 20:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.