Skip to content

Commit

Permalink
EditorConfig coding conventions (copied from dotnet/corefx) (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwe1ss authored Feb 13, 2018
1 parent be6f3ad commit c19817b
Show file tree
Hide file tree
Showing 35 changed files with 224 additions and 57 deletions.
160 changes: 160 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# editorconfig.org

# top-most EditorConfig file
root = true

# Default settings:
# A newline ending every file
# Use 4 spaces as indentation
[*]
insert_final_newline = true
indent_style = space
indent_size = 4

[project.json]
indent_size = 2

# C# files
[*.cs]
# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# only use var when it's obvious what the variable type is
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = false:suggestion

# use language keywords instead of BCL types
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style

dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const

dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style

dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static

dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style

dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal

dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

# Code style defaults
dotnet_sort_system_directives_first = true
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# Null checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = do_not_ignore
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# C++ Files
[*.{cpp,h,in}]
curly_bracket_next_line = true
indent_brace_style = Allman

# Xml project files
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2

# Xml build files
[*.builds]
indent_size = 2

# Xml files
[*.{xml,stylecop,resx,ruleset}]
indent_size = 2

# Xml config files
[*.{props,targets,config,nuspec}]
indent_size = 2

# Shell scripts
[*.sh]
end_of_line = lf
[*.{cmd, bat}]
end_of_line = crlf
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
Expand Down Expand Up @@ -46,9 +46,9 @@

###############################################################################
# diff behavior for common document formats
#
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ paket-files/

# JetBrains Rider
.idea/
*.sln.iml
*.sln.iml
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ env:
- DOTNET_CLI_TELEMETRY_OPTOUT: 1

script:
- ./build.sh
- ./build.sh
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"EditorConfig.EditorConfig",
"ms-vscode.csharp",
"ms-vscode.powershell"
]
}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
https://github.com/NuGet/Home/issues/4587#issuecomment-288913324 -->
<NoPackageAnalysis>true</NoPackageAnalysis>
</PropertyGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<clear />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion build-definition.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ Task dotnet-pack {

exec { dotnet pack $library -c $BuildConfiguration --version-suffix $BuildNumber --no-build --include-source --include-symbols -o $libraryOutput }
}
}
}
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Import-Module .\tools\psake\psake.psm1
Invoke-psake .\build-definition.ps1
Invoke-psake .\build-definition.ps1
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ echo ----------------------

for d in test/*/*.csproj; do
dotnet test $d -c $CONFIGURATION --no-build
done
done
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"sdk": {
"version": "2.1.4"
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/IScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public interface IScope : IDisposable
/// <summary>The <see cref="ISpan"/> that's been scoped by this <see cref="IScope"/></summary>
ISpan Span { get; }
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/IScopeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public interface IScopeManager
/// </returns>
IScope Activate(ISpan span, bool finishSpanOnClose);
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/ISpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ public interface ISpan
/// <seealso cref="ISpan.Context"/>
void Finish(DateTimeOffset finishTimestamp);
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/ISpanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ public interface ISpanBuilder
/// <seealso cref="StartActive(bool)"/>
ISpan Start();
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/ISpanContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public interface ISpanContext
/// <seealso cref="ISpan.GetBaggageItem"/>
IEnumerable<KeyValuePair<string, string>> GetBaggageItems();
}
}
}
8 changes: 4 additions & 4 deletions src/OpenTracing/ITracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace OpenTracing
{
/// <summary>Tracer is a simple, thin interface for Span creation and propagation across arbitrary transports.</summary>
/// <remarks>
/// Implementations should attempt to wrap exceptions in <see cref="OpenTracingException"/> or a derivative (e.g. by
/// Implementations should attempt to wrap exceptions in <see cref="OpenTracingException"/> or a derivative (e.g. by
/// passing the real exception into the ctor of <see cref="OpenTracingException"/>.
/// </remarks>
public interface ITracer
Expand All @@ -27,15 +27,15 @@ public interface ITracer
/// A contrived example:
/// <code>
/// ITracer tracer = ...
///
///
/// // Note if there is a ITracer.ActiveSpan(), it will be used as the target of an implicit CHILD_OF
/// // Refernece for "workSpan" when StartActive() is invoked.
/// using (IActiveSpan workSpan = tracer.BuildSpan("DoWork").StartActive())
/// {
/// workSpan.SetTag("...", "...");
/// // etc, etc
/// }
///
///
/// // It's also possible to create Spans manually, bypassing the ActiveSpanSource activation.
/// Span http = tracer.BuildSpan("HandleHTTPRequest")
/// .AsChildOf(rpcSpanContext) // an explicit parent
Expand Down Expand Up @@ -99,4 +99,4 @@ public interface ITracer
/// <seealso cref="BuiltinFormats"/>
ISpanContext Extract<TCarrier>(IFormat<TCarrier> format, TCarrier carrier);
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/LogFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ public static class LogFields
/// </example>
public const string Stack = "stack";
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/OpenTracingException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ protected OpenTracingException(string message, Exception innerException) : base(
{
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Propagation/BuiltinFormats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ public override string ToString()
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Propagation/IFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
public interface IFormat<TCarrier>
{
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Propagation/ITextMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public interface ITextMap : IEnumerable<KeyValuePair<string, string>>
/// <seealso cref="BuiltinFormats.HttpHeaders"/>
void Set(string key, string value);
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Propagation/TextMapExtractAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Propagation/TextMapInjectAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/References.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public static class References
/// </summary>
public const string FollowsFrom = "follows_from";
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Tag/AbstractTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ protected AbstractTag(string tagKey)

protected abstract void Set(ISpan span, TTagValue tagValue);
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Tag/BooleanTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ protected override void Set(ISpan span, bool tagValue)
span.SetTag(Key, tagValue);
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Tag/IntOrStringTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public void Set(ISpan span, string tagValue)
span.SetTag(Key, tagValue);
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenTracing/Tag/IntTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ protected override void Set(ISpan span, int tagValue)
span.SetTag(Key, tagValue);
}
}
}
}
Loading

0 comments on commit c19817b

Please sign in to comment.