From 75653af6232421c106bf889f3725bd2f795f82ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Caba=20=C5=A0agi?= Date: Mon, 16 Jan 2023 17:45:03 +0100 Subject: [PATCH 1/2] Add reproducers --- .../TestCases/InfiniteRecursion.RoslynCfg.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs index ad2db0e1fe0..5413db61b79 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs @@ -600,3 +600,38 @@ public IEnumerable Repeat(T element) // Noncompliant FP, it's not a recur } } } + +// https://github.com/SonarSource/sonar-dotnet/issues/6642 +public class Repro_6642 +{ + public int this[int i] + { + get { return this[i]; } // FN + set { this[i] = value; } // FN + } +} + +// https://github.com/SonarSource/sonar-dotnet/issues/6643 +public class Repro_6643 +{ + public static implicit operator byte(Repro_6643 d) => d; // FN +} + +// https://github.com/SonarSource/sonar-dotnet/issues/6644 +public delegate bool SomeDelegate(); + +public class Repro_6644 +{ + public event SomeDelegate OtherEvent + { + add + { + OtherEvent += value; // FN + } + + remove + { + OtherEvent -= value; // FN + } + } +} From 68b81beea534a23ea239974232bc881e4d512023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Caba=20=C5=A0agi?= Date: Tue, 17 Jan 2023 09:25:53 +0100 Subject: [PATCH 2/2] Rename event to not have confusion --- .../TestCases/InfiniteRecursion.RoslynCfg.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs index 5413db61b79..df346f536a3 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/InfiniteRecursion.RoslynCfg.cs @@ -622,16 +622,16 @@ public class Repro_6643 public class Repro_6644 { - public event SomeDelegate OtherEvent + public event SomeDelegate SomeEvent { add { - OtherEvent += value; // FN + SomeEvent += value; // FN } remove { - OtherEvent -= value; // FN + SomeEvent -= value; // FN } } }