From 0e0009bdf47f7d171789cd36e463360761230dff Mon Sep 17 00:00:00 2001 From: james_hargreaves Date: Mon, 3 Apr 2023 21:49:48 +0100 Subject: [PATCH 1/2] Include handling for SimpleMemberAccess --- .../CSharp/Analysis/RemoveRedundantParenthesesAnalyzer.cs | 3 ++- .../Analyzers.Tests/RCS1032RemoveRedundantParenthesesTests.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Analyzers/CSharp/Analysis/RemoveRedundantParenthesesAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveRedundantParenthesesAnalyzer.cs index fafd105da0..b1efae1c48 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveRedundantParenthesesAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveRedundantParenthesesAnalyzer.cs @@ -92,7 +92,8 @@ private static void AnalyzeParenthesizedExpression(SyntaxNodeAnalysisContext con case SyntaxKind.GreaterThanOrEqualExpression: case SyntaxKind.EqualsExpression: case SyntaxKind.NotEqualsExpression: - { + case SyntaxKind.SimpleMemberAccessExpression: + { if (expression.IsKind(SyntaxKind.IdentifierName) || expression is LiteralExpressionSyntax) { diff --git a/src/Tests/Analyzers.Tests/RCS1032RemoveRedundantParenthesesTests.cs b/src/Tests/Analyzers.Tests/RCS1032RemoveRedundantParenthesesTests.cs index eb2b48de97..58df6034f7 100644 --- a/src/Tests/Analyzers.Tests/RCS1032RemoveRedundantParenthesesTests.cs +++ b/src/Tests/Analyzers.Tests/RCS1032RemoveRedundantParenthesesTests.cs @@ -254,6 +254,7 @@ void M() [InlineData(@"M([|(|]""""));", @"M("""");")] [InlineData("var arr = new string[] { [|(|]null) };", "var arr = new string[] { null };")] [InlineData("var items = new List() { [|(|]null) };", "var items = new List() { null };")] + [InlineData("var x = [|(|]i).ToString();","var x = i.ToString();")] [InlineData(@"s = $""{[|(|]"""")}"";", @"s = $""{""""}"";")] [InlineData("[|(|]i) = [|(|]0);", "i = 0;")] [InlineData("[|(|]i) += [|(|]0);", "i += 0;")] From 25a5222719523cddc05418013d6c98178e4b987f Mon Sep 17 00:00:00 2001 From: james_hargreaves Date: Mon, 3 Apr 2023 21:52:34 +0100 Subject: [PATCH 2/2] with changeLog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index ed6c4c1a51..aaad6a71f5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [CLI] Analyze command does not create the XML output file and returns incorrect exit code when only compiler diagnostics are reported ([#1056](https://github.com/JosefPihrt/Roslynator/pull/1056) by @PeterKaszab). - [CLI] Fix exit code when multiple projects are processed ([#1061](https://github.com/JosefPihrt/Roslynator/pull/1061) by @PeterKaszab). - Fix code fix for CS0164 ([#1031](https://github.com/JosefPihrt/Roslynator/pull/1031)). +- Fix RCS1032 ([#1064](https://github.com/JosefPihrt/Roslynator/pull/1064)). ## [4.2.0] - 2022-11-27