Order modifiers (IDE0036)

Property Value
Rule ID IDE0036
Title Order modifiers
Category Style
Subcategory Language rules (modifier preferences)
Applicable languages C# and Visual Basic
Introduced version Visual Studio 2017
Options csharp_preferred_modifier_order


This rule lets you enforce a desired modifier sort order.

  • When this rule is enabled and the associated options are set to a list of modifiers, prefer the specified ordering.
  • When this rule is not enabled, no specific modifier order is preferred.


The associated options for this rule let you specify the desired modifier order for C# and Visual Basic, respectively.

For information about configuring options, see Option format.


Property Value Description
Option name csharp_preferred_modifier_order
Applicable languages C#
Option values One or more C# modifiers, such as public, private, and protected
Default option value public, private, protected, internal, file, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, required, volatile, async
// csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
class MyClass
    private static readonly int _daysInYear = 365;


Property Value Description
Option name visual_basic_preferred_modifier_order
Applicable languages Visual Basic
Option values One or more Visual Basic modifiers, such as Partial, Private, and Public
Default option value Partial, Default, Private, Protected, Public, Friend, NotOverridable, Overridable, MustOverride, Overloads, Overrides, MustInherit, NotInheritable, Static, Shared, Shadows, ReadOnly, WriteOnly, Dim, Const, WithEvents, Widening, Narrowing, Custom, Async
' visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async
Public Class MyClass
    Private Shared ReadOnly daysInYear As Int = 365
End Class

Suppress a warning

If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

#pragma warning disable IDE0036
// The code that's violating the rule is on this line.
#pragma warning restore IDE0036

To disable the rule for a file, folder, or project, set its severity to none in the configuration file.

dotnet_diagnostic.IDE0036.severity = none

To disable all of the code-style rules, set the severity for the category Style to none in the configuration file.

dotnet_analyzer_diagnostic.category-Style.severity = none

For more information, see How to suppress code analysis warnings.

See also