Skip to content

Instantly share code, notes, and snippets.

@henrygab
Created March 29, 2019 06:14
Show Gist options
  • Save henrygab/26f7494cd42bd4852f48633ae143a51c to your computer and use it in GitHub Desktop.
Save henrygab/26f7494cd42bd4852f48633ae143a51c to your computer and use it in GitHub Desktop.
Commented .editorconfig example source file
internal class Program
{
#region // CONST exception to .NET Guidelines prohibiting non-private fields (PascalCase)
public const int FooBar1 = 1; // Good (no warning) - Valid
internal const int FooBar2 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
protected internal const int FooBar3 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
protected const int FooBar4 = 1; // Good (no warning) - Valid
private protected const int FooBar5 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
private const int FooBar6 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
public const int fooBar1 = 1; // Good ( warning ) - Must be uppercase
internal const int fooBar2 = 1; // Good ( warning ) - .NET guidelines silent, Rule set C/D require PascalCase
protected internal const int fooBar3 = 1; // Good ( warning ) - .NET guidelines silent, Rule set C/D require PascalCase
protected const int fooBar4 = 1; // Good ( warning ) - Must be uppercase
private protected const int fooBar5 = 1; // Good ( warning ) - .NET guidelines silent, Rule set C/D require PascalCase
private const int fooBar6 = 1; // Good ( warning ) - .NET guidelines silent, Rule set C/D require PascalCase
#endregion // CONST exception to .NET Guidelines prohibiting non-private fields (PascalCase)
#region // STATIC READONLY exception to .NET Guidelines prohibiting non-private fields (PascalCase)
public static readonly int BarFoo1 = 1; // Good (no warning) - Valid
internal static readonly int BarFoo2 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
protected internal static readonly int BarFoo3 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
protected static readonly int BarFoo4 = 1; // Good (no warning) - Valid
private protected static readonly int BarFoo5 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
private static readonly int BarFoo6 = 1; // Good (no warning) - .NET guidelines silent, added via rule set C/D
public static readonly int barFoo1 = 1; // Good ( warning ) - Must be uppercase
internal static readonly int barFoo2 = 1; // Good ( warning ) - .NET guidelines silent, added via rule set C/D
protected internal static readonly int barFoo3 = 1; // Good ( warning ) - .NET guidelines silent, added via rule set C/D
protected static readonly int barFoo4 = 1; // Good ( warning ) - Must be uppercase
private protected static readonly int barFoo5 = 1; // Good ( warning ) - .NET guidelines silent, added via rule set C/D
private static readonly int barFoo6 = 1; // Good ( warning ) - .NET guidelines silent, added via rule set C/D
#endregion // STATIC READONLY exception to .NET Guidelines prohibiting non-private fields (PascalCase)
public static int BayWindow1 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
internal static int BayWindow2 = 1; // Good (no warning) - acceptable because only accessible within the current assembly
protected internal static int BayWindow3 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
protected static int BayWindow4 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
private protected static int BayWindow5 = 1; // Good (no warning) - acceptable because only accessible within the current assembly
private static int BayWindow6 = 1; // Good (no warning) - acceptable because fully private, no external access
public static int bayWindow1 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
internal static int bayWindow2 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because only accessible within the current assembly)
protected internal static int bayWindow3 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
protected static int bayWindow4 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
private protected static int bayWindow5 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because only accessible within the current assembly)
private static int bayWindow6 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because fully private)
public readonly int FunDay1 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
internal readonly int FunDay2 = 1; // Good (no warning) - acceptable because only accessible within the current assembly
protected internal readonly int FunDay3 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
protected readonly int FunDay4 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
private protected readonly int FunDay5 = 1; // Good (no warning) - acceptable because only accessible within the current assembly
private readonly int FunDay6 = 1; // Good (no warning) - acceptable because fully private, no external access
public readonly int funDay1 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
internal readonly int funDay2 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because only accessible within the current assembly)
protected internal readonly int funDay3 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
protected readonly int funDay4 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
private protected readonly int funDay5 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because only accessible within the current assembly)
private readonly int funDay6 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because fully private)
public int PenLight1 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
internal int PenLight2 = 1; // Good (no warning) - acceptable because only accessible within the current assembly
protected internal int PenLight3 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
protected int PenLight4 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
private protected int PenLight5 = 1; // Good (no warning) - acceptable because only accessible within the current assembly
private int PenLight6; // Good (no warning) - acceptable because fully private, no external access
public int penLight1 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
internal int penLight2 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because only accessible within the current assembly)
protected internal int penLight3 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
protected int penLight4 = 1; // Good ( warning ) - ____INVALID____ because public field is neither "static readonly" nor "const"
private protected int penLight5 = 1; // Good ( warning? ) - C/D/K require PascalCase (not invalid because only accessible within the current assembly)
private int penLight6; // Good ( warning? ) - C/D/K require PascalCase (not invalid because fully private)
private void Foo() // To get around warnings telling you fields must be readonly.
{
BayWindow6 = 1;
bayWindow6 = 1;
this.PenLight6 = 1;
this.penLight6 = 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment