Skip to content

Commit

Permalink
git gui, ading editor config and removing depenency on StyleCop.Analy…
Browse files Browse the repository at this point in the history
…zers (#228)
  • Loading branch information
amanbha committed Feb 18, 2020
1 parent b1157cb commit ea51561
Show file tree
Hide file tree
Showing 22 changed files with 224 additions and 125 deletions.
157 changes: 157 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
###############################
# Core EditorConfig Options #
###############################

root = true

# All files
[*]
indent_style = space

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom

###############################
# .NET Coding Conventions #
###############################

[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

# this. preferences
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent

# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_readonly_field = true:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_inferred_tuple_names = false:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:silent
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_compound_assignment = true

###############################
# Naming Conventions #
###############################

# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Use PascalCase for constant fields
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.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const

dotnet_code_quality_unused_parameters = false

###############################
# C# Code Style Rules #
###############################

[*.cs]
# var preferences
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent

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

# Pattern-matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion

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

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent

# Expression-level preferences
csharp_prefer_braces = true:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# Do not prefer static local functions
csharp_prefer_static_local_function = false

# Prefer simple using statements
csharp_prefer_simple_using_statement = true:silent

csharp_style_unused_value_assignment_preference = unused_local_variable
csharp_style_unused_value_expression_statement_preference = unused_local_variable

###############################
# C# Formatting Rules #
###############################

# 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_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_after_comma = true
csharp_space_after_dot = false

# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
7 changes: 6 additions & 1 deletion all.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCore", "AspNetCore",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dapr.Client.Grpc", "src\Dapr.Client.Grpc\Dapr.Client.Grpc.csproj", "{BCE5A721-69C5-4510-97ED-931ADE587466}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GrpcClient", "samples\Grpc\GrpcClient\GrpcClient.csproj", "{576B28F7-0D86-4C11-828A-B648E11863F6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GrpcClient", "samples\Grpc\GrpcClient\GrpcClient.csproj", "{576B28F7-0D86-4C11-828A-B648E11863F6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Grpc", "Grpc", "{9ED03812-9DDE-4DFE-9574-DF3671EECA25}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1BD1276E-D28A-45EA-89B1-6AD48471500D}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
19 changes: 0 additions & 19 deletions properties/dapr_managed_stylecop.props

This file was deleted.

21 changes: 0 additions & 21 deletions properties/stylecop/GlobalStylecopSuppressions.cs

This file was deleted.

11 changes: 0 additions & 11 deletions properties/stylecop/TestStylecopSuppressions.cs

This file was deleted.

21 changes: 0 additions & 21 deletions properties/stylecop/stylecop.json

This file was deleted.

3 changes: 1 addition & 2 deletions samples/Actor/DemoActor/DemoActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace DaprDemoActor
public class DemoActor : Actor, IDemoActor, IRemindable
{
private const string StateName = "my_data";
private IActorReminder reminder;

/// <summary>
/// Initializes a new instance of the <see cref="DemoActor"/> class.
Expand Down Expand Up @@ -63,7 +62,7 @@ public Task TestNoArgumentNoReturnType()
/// <inheritdoc/>
public async Task RegisterReminder()
{
this.reminder = await this.RegisterReminderAsync("TestReminder", null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));
await this.RegisterReminderAsync("TestReminder", null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));
}

/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions samples/Actor/IDemoActor/IDemoActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public class MyData
/// <inheritdoc/>
public override string ToString()
{
var propAValue = this.PropertyA == null ? "null" : this.PropertyA;
var propBValue = this.PropertyB == null ? "null" : this.PropertyB;
var propAValue = this.PropertyA ?? "null";
var propBValue = this.PropertyB ?? "null";
return $"PropertyA: {propAValue}, PropertyB: {propBValue}";
}
}
Expand Down
1 change: 0 additions & 1 deletion samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_managed_netcore.props" />
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_managed_stylecop.props" />

<PropertyGroup>
<!-- Set Output Path for samples-->
Expand Down
22 changes: 14 additions & 8 deletions samples/Grpc/GrpcClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace GrpcClient
/// </summary>
public class Program
{
private static string stateKeyName = "mykey";
private static string storeName = "statestore";
private static readonly string stateKeyName = "mykey";
private static readonly string storeName = "statestore";

/// <summary>
/// Main entry point.
Expand Down Expand Up @@ -53,8 +53,10 @@ public static async Task Main(string[] args)

private static async Task PublishEventAsync(Dapr.DaprClient client)
{
var data = new Any();
data.Value = ByteString.CopyFromUtf8("EventData");
var data = new Any
{
Value = ByteString.CopyFromUtf8("EventData")
};

// Create PublishEventEnvelope
var eventToPublish = new PublishEventEnvelope()
Expand All @@ -68,16 +70,20 @@ private static async Task PublishEventAsync(Dapr.DaprClient client)

private static async Task SaveStateAsync(Dapr.DaprClient client)
{
var value = new Any();
value.Value = ByteString.CopyFromUtf8("my data");
var value = new Any
{
Value = ByteString.CopyFromUtf8("my data")
};
var req = new StateRequest()
{
Key = stateKeyName,
Value = value,
};

var saveStateEnvelope = new SaveStateEnvelope();
saveStateEnvelope.StoreName = storeName;
var saveStateEnvelope = new SaveStateEnvelope
{
StoreName = storeName
};
saveStateEnvelope.Requests.Add(req);
_ = await client.SaveStateAsync(saveStateEnvelope);
Console.WriteLine("Saved State!");
Expand Down
8 changes: 4 additions & 4 deletions src/Dapr.Actors/Builder/ActorProxyGeneratorBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
Expand Down Expand Up @@ -122,7 +122,7 @@ internal static LocalBuilder CreateWrappedRequestBody(
{
// Cancellation token is tracked locally and should not be serialized and sent
// as a part of the request body.
parameterLength = parameterLength - 1;
parameterLength -= 1;
}

if (parameterLength == 0)
Expand All @@ -143,7 +143,7 @@ internal static LocalBuilder CreateWrappedRequestBody(
{
// Cancellation token is tracked locally and should not be serialized and sent
// as a part of the request body.
argsLength = argsLength - 1;
argsLength -= 1;
}

for (var i = 0; i < argsLength; i++)
Expand Down Expand Up @@ -309,7 +309,7 @@ private void AddAsyncMethodImplementation(
{
// Cancellation token is tracked locally and should not be serialized and sent
// as a part of the request body.
parameterLength = parameterLength - 1;
parameterLength -= 1;
}

LocalBuilder requestMessage = null;
Expand Down
4 changes: 1 addition & 3 deletions src/Dapr.Actors/Builder/InterfaceDetailsStore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
Expand All @@ -14,8 +14,6 @@ namespace Dapr.Actors.Builder

internal class InterfaceDetailsStore
{
private const string TraceType = "InterfaceDetailsStore";

private readonly ConcurrentDictionary<int, InterfaceDetails> knownTypesMap =
new ConcurrentDictionary<int, InterfaceDetails>();

Expand Down
4 changes: 2 additions & 2 deletions src/Dapr.Actors/Communication/ActorLogicalCallContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
Expand All @@ -9,7 +9,7 @@ namespace Dapr.Actors.Communication

internal static class ActorLogicalCallContext
{
private static AsyncLocal<string> fabActAsyncLocal = new AsyncLocal<string>();
private static readonly AsyncLocal<string> fabActAsyncLocal = new AsyncLocal<string>();

public static bool IsPresent()
{
Expand Down
Loading

0 comments on commit ea51561

Please sign in to comment.