S6853 not recognising asp-for

Make sure to read this post before raising a thread here:

Then tell us:

  • What language is this for?

Razor / cshtml

  • Which rule?

Web>S6853

  • Why do you believe it’s a false-positive/false-negative?

Rule states there must be a for= attribute (or be nested) - Razor / asp.net replaces this / applies this via asp-for= attributes

  • Are you using
    • SonarQube for IDE - which IDE/version?

SonarQube IDE 9.0.0.15771 for Visual Studio 18.0.0

  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

Example

                <div>
                    <div>
                        <label asp-for='ModelProperty'></label>
                    </div>
                    <div>
                        <input asp-for='ModelProperty' />
                    </div>
                </div>

Hello @marc.free,

thanks for reporting this. I’ve created a ticket to fix it.

Cheers!