Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S6964: Issue is reported on the attribute instead of the property #9282

Closed
mary-georgiou-sonarsource opened this issue May 15, 2024 · 0 comments · Fixed by #9332
Closed

S6964: Issue is reported on the attribute instead of the property #9282

mary-georgiou-sonarsource opened this issue May 15, 2024 · 0 comments · Fixed by #9332
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements
Milestone

Comments

@mary-georgiou-sonarsource
Copy link
Contributor

mary-georgiou-sonarsource commented May 15, 2024

When a model property is annotated with any attribute the issue is reported on the attribute instead of the property which is confusing.

using System;
using Microsoft.AspNetCore.Mvc;

  public class Model
  {
      public int ValueProperty { get; set; }        // Noncompliant

      [Custom]                                      // Noncompliant
      public int ValuePropertyAnnotatedWithCustomAttribute { get; set; } // The issue should be raised here, and not on the attribute above.
  }

  public class DerivedFromController : Controller
  {
      [HttpPost] public IActionResult Create(Model model) => View(model);
  }
  
  public class CustomAttribute : Attribute { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants