Skip to content

Commit

Permalink
S2589: Add FP repro for #9051 (#9052)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Pohlmann authored Apr 10, 2024
1 parent f5c7f47 commit b169775
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;

namespace Tests.Diagnostics
Expand Down Expand Up @@ -319,3 +320,16 @@ public int TupleWithDeclaration(string name1, string name2) =>
(var x, _) => -1, // Noncompliant - FP
};
}

// https://github.com/SonarSource/sonar-dotnet/issues/9051
class Repro_9051
{
string Method(bool b) =>
TrySomething(out var s) switch
{
true => s,
false => "" // Noncompliant FP
};

bool TrySomething([NotNullWhen(true)] out string outValue) => throw new NotImplementedException();
}

0 comments on commit b169775

Please sign in to comment.