Skip to content

Commit

Permalink
Add S3900 FP repro for #2639
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-zurn-sonarsource committed Nov 7, 2019
1 parent 28a3602 commit df06e27
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,17 @@ public void Compliant1(object o)
}
}

[AttributeUsage(AttributeTargets.Parameter)]
public sealed class ValidatedNotNullAttribute : Attribute { }

public static class GuardExtensionClass
{
public static void GuardExtension([ValidatedNotNull]this string value) { }
}

public class GuardedTests
{
public void Guarded(string s1, string s2, string s3)
public void Guarded(string s1, string s2, string s3, string s4, string s5)
{
Guard1(s1);
s1.ToUpper();
Expand All @@ -123,6 +131,12 @@ public void Guarded(string s1, string s2, string s3)

Guard3("s3", s3);
s3.ToUpper();

Guard4(s4);
s4.ToUpper();

s5.GuardExtension();
s5.ToUpper(); // Noncompliant - FP for extensions having the [ValidatedNotNull] attribute
}

public void Guard1<T>([ValidatedNotNull]T value) where T : class { }
Expand All @@ -131,8 +145,7 @@ public void Guard2<T>([ValidatedNotNull]T value, string name) where T : class {

public void Guard3<T>(string name, [ValidatedNotNull]T value) where T : class { }

[AttributeUsage(AttributeTargets.Parameter)]
public sealed class ValidatedNotNullAttribute : Attribute { }
public static void Guard4<T>([ValidatedNotNull]T value) where T : class { }
}

public class ReproIssue2476
Expand Down

0 comments on commit df06e27

Please sign in to comment.