From 47c5d92b873f8d7f419ee10afe5a0eb743027257 Mon Sep 17 00:00:00 2001 From: Krzysztof Kasprowicz <60486987+Krzysztof318@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:31:02 +0200 Subject: [PATCH] .Net: Fixed ReSharper/Rider errors to be compliant with dotnet formatting settings (#5862) ### Motivation and Context Related to #4653 Before changes, VS studio with resharper or Rider showed many errors and warnings. But without resharper, VS studio shows 0 errors and 0 warnings like on screenshot. ![vs_studio_without_resharper](https://github.com/microsoft/semantic-kernel/assets/60486987/90824f8d-5273-453d-9a60-9f3e5010a21a) For Rider/Resharper (errors only): ![rider_errors_before](https://github.com/microsoft/semantic-kernel/assets/60486987/53eff93b-a036-4b8c-911f-9e4b4ebc8205) ### Description Now, after changes in .editorconfig for these developers which are using resharper/rider will show only resharper warnings, errors are empty like in VS studio. ![rider_errors_after](https://github.com/microsoft/semantic-kernel/assets/60486987/46cab9b6-6df4-4e8c-9a18-814be129c467) All disabled or changed to suggestion/warning rules were visible as errors before. I also was forced to update the`SK-dotnet.sln.DotSettings` file due to the new resharper version 2024.1 ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone :smile: --------- Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com> Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com> --- .editorconfig | 33 ++++++++++++++++++++++++++++++++ dotnet/SK-dotnet.sln.DotSettings | 12 ++++++++++++ 2 files changed, 45 insertions(+) diff --git a/.editorconfig b/.editorconfig index 6504d45cdef0..e885cbd94dd0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -368,6 +368,39 @@ csharp_style_prefer_top_level_statements = true:silent csharp_style_expression_bodied_lambdas = true:silent csharp_style_expression_bodied_local_functions = false:silent +############################### +# Resharper Rules # +############################### + +# Resharper disabled rules: https://www.jetbrains.com/help/resharper/Reference__Code_Inspections_CSHARP.html#CodeSmell +resharper_redundant_linebreak_highlighting = none # Disable Resharper's "Redundant line break" highlighting +resharper_missing_linebreak_highlighting = none # Disable Resharper's "Missing line break" highlighting +resharper_bad_empty_braces_line_breaks_highlighting = none # Disable Resharper's "Bad empty braces line breaks" highlighting +resharper_missing_indent_highlighting = none # Disable Resharper's "Missing indent" highlighting +resharper_missing_blank_lines_highlighting = none # Disable Resharper's "Missing blank lines" highlighting +resharper_wrong_indent_size_highlighting = none # Disable Resharper's "Wrong indent size" highlighting +resharper_bad_indent_highlighting = none # Disable Resharper's "Bad indent" highlighting +resharper_bad_expression_braces_line_breaks_highlighting = none # Disable Resharper's "Bad expression braces line breaks" highlighting +resharper_multiple_spaces_highlighting = none # Disable Resharper's "Multiple spaces" highlighting +resharper_bad_expression_braces_indent_highlighting = none # Disable Resharper's "Bad expression braces indent" highlighting +resharper_bad_control_braces_indent_highlighting = none # Disable Resharper's "Bad control braces indent" highlighting +resharper_bad_preprocessor_indent_highlighting = none # Disable Resharper's "Bad preprocessor indent" highlighting +resharper_redundant_blank_lines_highlighting = none # Disable Resharper's "Redundant blank lines" highlighting +resharper_multiple_statements_on_one_line_highlighting = none # Disable Resharper's "Multiple statements on one line" highlighting +resharper_bad_braces_spaces_highlighting = none # Disable Resharper's "Bad braces spaces" highlighting +resharper_outdent_is_off_prev_level_highlighting = none # Disable Resharper's "Outdent is off previous level" highlighting +resharper_bad_symbol_spaces_highlighting = none # Disable Resharper's "Bad symbol spaces" highlighting +resharper_bad_colon_spaces_highlighting = none # Disable Resharper's "Bad colon spaces" highlighting +resharper_bad_semicolon_spaces_highlighting = none # Disable Resharper's "Bad semicolon spaces" highlighting +resharper_bad_square_brackets_spaces_highlighting = none # Disable Resharper's "Bad square brackets spaces" highlighting +resharper_bad_parens_spaces_highlighting = none # Disable Resharper's "Bad parens spaces" highlighting + +# Resharper enabled rules: https://www.jetbrains.com/help/resharper/Reference__Code_Inspections_CSHARP.html#CodeSmell +resharper_comment_typo_highlighting = suggestion # Resharper's "Comment typo" highlighting +resharper_redundant_using_directive_highlighting = warning # Resharper's "Redundant using directive" highlighting +resharper_inconsistent_naming_highlighting = warning # Resharper's "Inconsistent naming" highlighting +resharper_redundant_this_qualifier_highlighting = warning # Resharper's "Redundant 'this' qualifier" highlighting +resharper_arrange_this_qualifier_highlighting = warning # Resharper's "Arrange 'this' qualifier" highlighting ############################### # Java Coding Conventions # diff --git a/dotnet/SK-dotnet.sln.DotSettings b/dotnet/SK-dotnet.sln.DotSettings index e0c9ed70c24e..98d24f7d7f34 100644 --- a/dotnet/SK-dotnet.sln.DotSettings +++ b/dotnet/SK-dotnet.sln.DotSettings @@ -131,6 +131,17 @@ <Policy Inspect="True" Prefix="s_" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="Async" Style="AaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local variables"><ElementKinds><Kind Name="LOCAL_VARIABLE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="Async" Style="aaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Constant fields (not private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local functions"><ElementKinds><Kind Name="LOCAL_FUNCTION" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="Async" Style="AaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Methods"><ElementKinds><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="Async" Style="AaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Parameters"><ElementKinds><Kind Name="PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="Async" Style="aaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"><ElementKinds><Kind Name="NAMESPACE" /><Kind Name="CLASS" /><Kind Name="STRUCT" /><Kind Name="ENUM" /><Kind Name="DELEGATE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"><ElementKinds><Kind Name="LOCAL_CONSTANT" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB"><ExtraRule Prefix="" Suffix="" Style="aaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Properties"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="Async" Style="AaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="s_" Suffix="" Style="aaBb" /></Policy> 2 False @@ -146,6 +157,7 @@ True True True + True True False TRACE