From 4695c7c36eccb765abb5498852cee612323ddb33 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 15:14:16 +0500 Subject: [PATCH 01/14] Added linter for csharp --- .github/workflows/csharp.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 5bb5b788..4ae22fac 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -8,6 +8,23 @@ on: branches: [ master ] jobs: + lint_code_base: + runs-on: ubuntu-latest + name: Lint Code Base + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_CSHARP: true + lint_markdown_files: runs-on: ubuntu-latest steps: From c0bcaf3b9780b40170ed4dc7f81c24d34a6289fc Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 15:24:56 +0500 Subject: [PATCH 02/14] test --- .github/workflows/csharp.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 4ae22fac..96852790 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -23,7 +23,6 @@ jobs: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_CSHARP: true lint_markdown_files: runs-on: ubuntu-latest From 7a6ee01847d8fb3b2e1424c799066e074c58f2b5 Mon Sep 17 00:00:00 2001 From: mnoman09 Date: Mon, 23 May 2022 15:56:15 +0500 Subject: [PATCH 03/14] added wrong indentiton --- OptimizelySDK/OptlyConfig/OptimizelyAudience.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs b/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs index 88d2119f..8386d5bf 100644 --- a/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs +++ b/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs @@ -16,13 +16,18 @@ namespace OptimizelySDK.OptlyConfig { + //wrong comment indentation public class OptimizelyAudience { /// /// Audience ID /// - public string Id { get; set; } - + public string Id { // Get universal answer (bad) + get; + set; + } + // TODO: + // KLUDGE: /// /// Audience Name /// @@ -38,6 +43,8 @@ public OptimizelyAudience(string id, string name, object conditions) Id = id; Name = name; Conditions = conditions; + // Avoid magic numbers + var circleArea = 3.141592653589 * Math.Pow(radius, 2); } } } From 449fbea5ecdefab1fecd13b69df570fcc765d981 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 15:59:28 +0500 Subject: [PATCH 04/14] Fixed yml linting issues --- .github/workflows/csharp.yml | 115 ++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 96852790..1587b4e4 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -1,11 +1,11 @@ - +--- name: Csharp CI with .NET on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: lint_code_base: @@ -15,7 +15,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 with: - # Full git history is needed to get a proper list of changed files within `super-linter` + # Full git history is needed to get a proper list of changed files fetch-depth: 0 - name: Lint Code Base uses: github/super-linter@v4 @@ -27,17 +27,18 @@ jobs: lint_markdown_files: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.6' - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: Install gem - run: | - gem install awesome_bot - - name: Run tests - run: find . -type f -name '*.md' -exec awesome_bot {} \; + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.6' + # runs 'bundle install' and caches installed gems automatically + bundler-cache: true + - name: Install gem + run: | + gem install awesome_bot + - name: Run tests + run: find . -type f -name '*.md' -exec awesome_bot {} \; integration_tests: uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@master @@ -56,54 +57,54 @@ jobs: unit_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.x - - name: Restore nuget packages - run: | - nuget restore OptimizelySDK.Travis.sln - nuget install ./OptimizelySDK.Tests/packages.config -OutputDirectory ./packages - nuget install NUnit.Runners -Version 2.6.4 -OutputDirectory ./testrunner - - name: script - run: | - ./install_mono.sh - xbuild /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk /p:Configuration=Release ./OptimizelySDK.Travis.sln - mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe ./OptimizelySDK.Tests/bin/Release/OptimizelySDK.Tests.dll - - name: find and sign dll - run: | - sudo find . -path './OptimizelySDK*bin/Release/OptimizelySDK*.dll' -not -regex '.*Tests.*' -print0 | while IFS= read -r -d '' file; do sn -R $file ./keypair.snk; done + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + - name: Restore nuget packages + run: | + nuget restore OptimizelySDK.Travis.sln + nuget install ./OptimizelySDK.Tests/packages.config -OutputDirectory ./packages + nuget install NUnit.Runners -Version 2.6.4 -OutputDirectory ./testrunner + - name: script + run: | + ./install_mono.sh + xbuild /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk /p:Configuration=Release ./OptimizelySDK.Travis.sln + mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe ./OptimizelySDK.Tests/bin/Release/OptimizelySDK.Tests.dll + - name: find and sign dll + run: | + sudo find . -path './OptimizelySDK*bin/Release/OptimizelySDK*.dll' -not -regex '.*Tests.*' -print0 | while IFS= read -r -d '' file; do sn -R $file ./keypair.snk; done netStandard16: runs-on: windows-2022 steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 3.1.x - - name: Restore dependencies - run: dotnet restore OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj - - name: Build - run: | - # strongname signing is taken care of in build step - dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release - # TODO: no dotnet test yet for NetStandard16 + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 3.1.x + - name: Restore dependencies + run: dotnet restore OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj + - name: Build + run: | + # strongname signing is taken care of in build step + dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release + # TODO: no dotnet test yet for NetStandard16 netStandard20: runs-on: windows-2022 steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 3.1.x - - name: Restore dependencies - run: dotnet restore OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj - - name: Build - run: | - # strongname signing is taken care of in build step - dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release - # TODO: no dotnet test yet for NetStandard16 + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 3.1.x + - name: Restore dependencies + run: dotnet restore OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj + - name: Build + run: | + # strongname signing is taken care of in build step + dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release + # TODO: no dotnet test yet for NetStandard16 From dcb194fa2a1f1310286e3b51a9a2fdc297877846 Mon Sep 17 00:00:00 2001 From: mnoman09 Date: Mon, 23 May 2022 16:12:55 +0500 Subject: [PATCH 05/14] removed mATH --- OptimizelySDK/OptlyConfig/OptimizelyAudience.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs b/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs index 8386d5bf..73720dc3 100644 --- a/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs +++ b/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs @@ -44,7 +44,6 @@ public OptimizelyAudience(string id, string name, object conditions) Name = name; Conditions = conditions; // Avoid magic numbers - var circleArea = 3.141592653589 * Math.Pow(radius, 2); - } + } } } From 9179e50fda92a9b08878a04757cd232fe5de3891 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 16:36:19 +0500 Subject: [PATCH 06/14] test --- .github/workflows/csharp.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 1587b4e4..03a4aa24 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -20,9 +20,10 @@ jobs: - name: Lint Code Base uses: github/super-linter@v4 env: - VALIDATE_ALL_CODEBASE: false + VALIDATE_ALL_CODEBASE: true DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_CSHARP: true lint_markdown_files: runs-on: ubuntu-latest From 85b64c4a9947a7182211def2c64a712be2c56b41 Mon Sep 17 00:00:00 2001 From: muhammadnoman Date: Mon, 23 May 2022 19:09:10 +0500 Subject: [PATCH 07/14] testing by adding editorconfig --- OptimizelySDK/.editorconfig | 124 ++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 OptimizelySDK/.editorconfig diff --git a/OptimizelySDK/.editorconfig b/OptimizelySDK/.editorconfig new file mode 100644 index 00000000..bb56bbd6 --- /dev/null +++ b/OptimizelySDK/.editorconfig @@ -0,0 +1,124 @@ +# To learn more about .editorconfig see https://aka.ms/editorconfigdocs +############################### +# 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 +# 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:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +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 +############################### +# 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 +############################### +# C# Coding Conventions # +############################### +[*.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:suggestion +# 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 +############################### +# 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 +# Wrapping preferences +csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true +############################### +# VB Coding Conventions # +############################### +[*.vb] +# Modifier preferences +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:suggestion From e479fed56b1f2583fae80d7ad0c7282c842ccc82 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 19:15:30 +0500 Subject: [PATCH 08/14] test --- .github/workflows/csharp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 03a4aa24..7e7197d8 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -20,7 +20,7 @@ jobs: - name: Lint Code Base uses: github/super-linter@v4 env: - VALIDATE_ALL_CODEBASE: true + VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_CSHARP: true From eef7f1a61b906fb2d2e7d851b40b3db463297d54 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 19:26:49 +0500 Subject: [PATCH 09/14] test --- .github/workflows/csharp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 7e7197d8..d727b37a 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -23,7 +23,7 @@ jobs: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_CSHARP: true + EDITORCONFIG_FILE_NAME: .editorconfig lint_markdown_files: runs-on: ubuntu-latest From abf8f7081d17d7ee650531b507f7a2c0de91b865 Mon Sep 17 00:00:00 2001 From: mnoman09 Date: Mon, 23 May 2022 19:45:37 +0500 Subject: [PATCH 10/14] test --- OptimizelySDK/.editorconfig => .editorconfig | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename OptimizelySDK/.editorconfig => .editorconfig (100%) diff --git a/OptimizelySDK/.editorconfig b/.editorconfig similarity index 100% rename from OptimizelySDK/.editorconfig rename to .editorconfig From d3115e2ffb26a0e15e971e5ec2638912a793cebb Mon Sep 17 00:00:00 2001 From: mnoman09 Date: Mon, 23 May 2022 20:03:06 +0500 Subject: [PATCH 11/14] test --- .editorconfig => .automation/.editorconfig | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .editorconfig => .automation/.editorconfig (100%) diff --git a/.editorconfig b/.automation/.editorconfig similarity index 100% rename from .editorconfig rename to .automation/.editorconfig From 3e51264b22c24c524b3d513cea36bc96d91e2b34 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Mon, 23 May 2022 20:13:19 +0500 Subject: [PATCH 12/14] test --- .github/workflows/csharp.yml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index d727b37a..9d2d992e 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -23,24 +23,9 @@ jobs: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - EDITORCONFIG_FILE_NAME: .editorconfig + VALIDATE_CSHARP: true + VALIDATE_MARKDOWN: true - lint_markdown_files: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.6' - # runs 'bundle install' and caches installed gems automatically - bundler-cache: true - - name: Install gem - run: | - gem install awesome_bot - - name: Run tests - run: find . -type f -name '*.md' -exec awesome_bot {} \; - integration_tests: uses: optimizely/csharp-sdk/.github/workflows/integration_test.yml@master secrets: From e2a6d8c5b907c1c4cb850debf595be1c47b3ecff Mon Sep 17 00:00:00 2001 From: mnoman09 Date: Mon, 23 May 2022 20:15:48 +0500 Subject: [PATCH 13/14] test --- .automation/.editorconfig | 124 --------- .editorconfig | 242 ++++++++++++++++++ .../OptlyConfig/OptimizelyAudience.cs | 12 +- 3 files changed, 245 insertions(+), 133 deletions(-) delete mode 100644 .automation/.editorconfig create mode 100644 .editorconfig diff --git a/.automation/.editorconfig b/.automation/.editorconfig deleted file mode 100644 index bb56bbd6..00000000 --- a/.automation/.editorconfig +++ /dev/null @@ -1,124 +0,0 @@ -# To learn more about .editorconfig see https://aka.ms/editorconfigdocs -############################### -# 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 -# 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:silent -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -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 -############################### -# 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 -############################### -# C# Coding Conventions # -############################### -[*.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:suggestion -# 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 -############################### -# 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 -# Wrapping preferences -csharp_preserve_single_line_statements = true -csharp_preserve_single_line_blocks = true -############################### -# VB Coding Conventions # -############################### -[*.vb] -# Modifier preferences -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:suggestion diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..a461d772 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,242 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = block_scoped:silent + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +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_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# 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 = false +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 + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +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 = suggestion +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 = suggestion +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 + +# 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.types.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.non_field_members.required_modifiers = + +# 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 + +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion diff --git a/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs b/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs index 73720dc3..88d2119f 100644 --- a/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs +++ b/OptimizelySDK/OptlyConfig/OptimizelyAudience.cs @@ -16,18 +16,13 @@ namespace OptimizelySDK.OptlyConfig { - //wrong comment indentation public class OptimizelyAudience { /// /// Audience ID /// - public string Id { // Get universal answer (bad) - get; - set; - } - // TODO: - // KLUDGE: + public string Id { get; set; } + /// /// Audience Name /// @@ -43,7 +38,6 @@ public OptimizelyAudience(string id, string name, object conditions) Id = id; Name = name; Conditions = conditions; - // Avoid magic numbers - } + } } } From 72044b2f1bb1508803d794bd00a39581ab2d11ce Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Tue, 24 May 2022 19:04:51 +0500 Subject: [PATCH 14/14] removed github_token from passing it to linter --- .github/workflows/csharp.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 9d2d992e..defc468a 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -22,7 +22,6 @@ jobs: env: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_CSHARP: true VALIDATE_MARKDOWN: true