From b0c4613c6b3c19b287675a5de01c4d7d52f9a722 Mon Sep 17 00:00:00 2001 From: Mary Georgiou <89914005+mary-georgiou-sonarsource@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:57:28 +0100 Subject: [PATCH] Update coding example --- rules/S6932/csharp/rule.adoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rules/S6932/csharp/rule.adoc b/rules/S6932/csharp/rule.adoc index c8575414a8c..51d0db97fbe 100644 --- a/rules/S6932/csharp/rule.adoc +++ b/rules/S6932/csharp/rule.adoc @@ -141,14 +141,6 @@ public ActionResult Post() var cultureName = Request.QueryString["locale"] ?? "en-US"; // Noncompliant: Request.QueryString // .. } - -public IActionResult Post() -{ - var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via variable - var name = Request.Form["name"]; // Compliant: Access via constant and variable keys is mixed - var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed - // .. -} ---- ==== Compliant solution @@ -170,6 +162,14 @@ public ActionResult Post(User user, [Bind(Prefix = "locale")] string cultureName // ... } } + +public IActionResult Post() +{ + var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via variable + var name = Request.Form["name"]; // Compliant: Access via constant and variable keys is mixed + var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed + // .. +} ---- include::../how-does-this-work.adoc[]