Skip to content

Commit

Permalink
S2259: Add FP repro for #6241
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-mikula-sonarsource committed Oct 25, 2022
1 parent e11100d commit 2bd1cb4
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1703,3 +1703,33 @@ public void StringIsNullOrEmpty(string value)
}
}
}

// https://github.com/SonarSource/sonar-dotnet/issues/6241
public class Repro_6241<T>
{
public void WithGenericValue()
{
HashSet<T> value = null;
if (value is null)
{
value.ToString(); // FN
}
else
{
value.ToString(); // Noncompliant FP
}
}

public void WithNormalValue(List<object> inputs)
{
HashSet<object> value = null;
if (value is null)
{
value.ToString(); // Noncompliant
}
else
{
value.ToString(); // Compliant
}
}
}

0 comments on commit 2bd1cb4

Please sign in to comment.