Skip to content

Commit

Permalink
(GH-286) Add basic naming rules for types
Browse files Browse the repository at this point in the history
This commit adds some basic naming rules in
the editorconfig configuration file that can be
displayed when running Visual Studio.
Unfortunately this can not at this moment be
respected when running dotnet build.
  • Loading branch information
AdmiringWorm authored and gep13 committed Dec 29, 2020
1 parent dfaf0b8 commit 3e6449a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
*.rtf diff=astextplain
*.RTF diff=astextplain

*.png binary
*.png binary

.editorconfig text whitespace=-blank-at-eol
90 changes: 89 additions & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ dotnet_diagnostic.SA1202.severity = none
# SA1309: Field names should not begin with underscore
dotnet_diagnostic.SA1309.severity = none

# SA1310: Field names should not contain an underscore
dotnet_diagnostic.SA1310.severity = none

# SA1404: Code analysis suppressions should have justification
dotnet_diagnostic.SA1404.severity = none

Expand Down Expand Up @@ -55,6 +58,9 @@ dotnet_diagnostic.SA1404.severity = none
# SA1101: Prefix local calls with this
dotnet_diagnostic.SA1101.severity = none

# SA1300: Element should begin with an uppercase letter
dotnet_diagnostic.SA1300.severity = error

# SA1633: File should have header
dotnet_diagnostic.SA1633.severity = none

Expand Down Expand Up @@ -83,4 +89,86 @@ dotnet_diagnostic.RCS1079.severity = warning
dotnet_diagnostic.RCS1057.severity = none

# IDE0004: Remove Unnecessary Cast
dotnet_diagnostic.IDE0004.severity = warning
dotnet_diagnostic.IDE0004.severity = warning

#### Naming styles ####

## Note, these rules are currently on available in Visual Studio
## not when building using dotnet

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = error
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = error
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.field_members_should_be_camel_case_underscored.severity = error
dotnet_naming_rule.fields_should_use_camel_case_underscored.symbols = field_members
dotnet_naming_rule.fields_should_use_camel_case_underscored.style = camel_case_underscore

dotnet_naming_rule.async_method_should_have_async_suffix.severity = error
dotnet_naming_rule.async_method_should_have_async_suffix.symbols = async_methods_only
dotnet_naming_rule.async_method_should_have_async_suffix.style = async_pascal_case

dotnet_naming_rule.constant_fields_should_use_all_uppercase.severity = error
dotnet_naming_rule.constant_fields_should_use_all_uppercase.symbols = constant_field_members
dotnet_naming_rule.constant_fields_should_use_all_uppercase.style = all_uppercase

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected

dotnet_naming_symbols.field_members.applicable_kinds = field
dotnet_naming_symbols.field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected

dotnet_naming_symbols.async_methods_only.applicable_kinds = method
dotnet_naming_symbols.async_methods_only.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.async_methods_only.required_modifiers = async

dotnet_naming_symbols.constant_field_members.applicable_kinds = field
dotnet_naming_symbols.constant_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.constant_field_members.required_modifiers = const

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.camel_case_underscore.required_prefix = _
dotnet_naming_style.camel_case_underscore.required_suffix =
dotnet_naming_style.camel_case_underscore.word_separator =
dotnet_naming_style.camel_case_underscore.capitalization = camel_case

dotnet_naming_style.async_pascal_case.required_prefix =
dotnet_naming_style.async_pascal_case.required_suffix = Async
dotnet_naming_style.async_pascal_case.word_separator =
dotnet_naming_style.async_pascal_case.capitalization = pascal_case

dotnet_naming_style.all_uppercase.required_prefix =
dotnet_naming_style.all_uppercase.required_suffix =
dotnet_naming_style.all_uppercase.word_separator = _
dotnet_naming_style.all_uppercase.capitalization = all_upper
5 changes: 4 additions & 1 deletion src/GitReleaseManager.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class Program
{
private static IServiceProvider _serviceProvider;

[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "The main entry point can not be named with an Async Suffix")]
private static async Task<int> Main(string[] args)
{
// Just add the TLS 1.2 protocol to the Service Point manager until
Expand Down Expand Up @@ -134,7 +135,9 @@ private static void CreateFiglet(BaseSubOptions options)
}

var version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
if (version.Contains("+", StringComparison.Ordinal))
#pragma warning disable CA1307 // Specify StringComparison ; Reason, we can't do this because of targeting .NET Framework
if (version.Contains("+"))
#pragma warning restore CA1307 // Specify StringComparison
{
version = version.Substring(0, version.IndexOf("+", StringComparison.Ordinal));
}
Expand Down

0 comments on commit 3e6449a

Please sign in to comment.