Daniil Palii
Daniil Palii

Reputation: 1230

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

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.

Upvotes: 8

Views: 3248

Answers (2)

prlcutting
prlcutting

Reputation: 379

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.

Upvotes: 2

JL0PD
JL0PD

Reputation: 4508

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

Upvotes: 3

Related Questions