Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 688 Bytes

File metadata and controls

49 lines (39 loc) · 688 Bytes

GCop 136

"All constants and class fields should be defined at the top of the class, before all methods."

Rule description

According to the StyleCop Rules Documentation the ordering of items in a class is as follows:

  • Constant Fields
  • Fields
  • Constructors
  • Finalizers (Destructors)
  • Delegates
  • Events
  • Enums
  • Interfaces
  • Properties
  • Indexers
  • Methods
  • Structs
  • Classes

Example

public class Bar
{
    public void Foo() 
    {
        ...
    }
    private const string fooBar = "someText";

}

should be 🡻

public class Bar
{
    private const string fooBar = "someText";
    
    public void Foo() 
    {
        ...
    }

}