Skip to content

Commit

Permalink
S6964: Add FP repro for #9275 (#9281)
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource authored May 16, 2024
1 parent 761e070 commit 89eca87
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void AvoidUnderPosting_CSharp9() =>
[TestMethod]
public void AvoidUnderPosting_CSharp12() =>
builder.AddPaths("AvoidUnderPosting.CSharp12.cs")
.AddReferences(NuGetMetadataReference.SystemTextJson("7.0.4"))
.WithOptions(ParseOptionsHelper.FromCSharp12)
.Verify();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace CSharp12
{
Expand All @@ -20,3 +22,25 @@ public class DerivedFromController : Controller
[HttpDelete] public IActionResult Remove(ModelWithPrimaryAndParameterlessConstructor model) => View(model);
}
}

namespace Repro9275
{
// Repro https://github.com/SonarSource/sonar-dotnet/issues/9275
public class Model
{
public int ValueProperty { get; set; } // Noncompliant

[Custom] // Noncompliant repro for https://github.com/SonarSource/sonar-dotnet/issues/9282
public int ValuePropertyAnnotatedWithCustomAttribute { get; set; }

[JsonRequired] // Noncompliant - FP because the attribute is annotated with JsonRequiredAttribute
public int AnotherValueProperty { get; set; }
}

public class DerivedFromController : Controller
{
[HttpPost] public IActionResult Create(Model model) => View(model);
}

public class CustomAttribute : Attribute { }
}

0 comments on commit 89eca87

Please sign in to comment.