From e5da0b90ceba324e69ab39642f13e1f64e98b819 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 10 Sep 2025 14:03:42 +0200 Subject: [PATCH 1/2] C#: Deprecate cs/captured-foreach-variable. --- csharp/ql/src/Language Abuse/ForeachCapture.ql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/csharp/ql/src/Language Abuse/ForeachCapture.ql b/csharp/ql/src/Language Abuse/ForeachCapture.ql index 0148796a2e72..2f8346817a6f 100644 --- a/csharp/ql/src/Language Abuse/ForeachCapture.ql +++ b/csharp/ql/src/Language Abuse/ForeachCapture.ql @@ -1,4 +1,6 @@ /** + * @deprecated This query is no longer relevant as the semantics of capturing a 'foreach' variable + * and using it outside the loop has been stable since C# version 5. * @name Capturing a foreach variable * @description Code that captures a 'foreach' variable and uses it outside the loop behaves differently in C# version 4 and C# version 5 * @kind problem From 186e42b1fe22c346e2c5128a855dd70833bcc2fd Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 10 Sep 2025 14:02:30 +0200 Subject: [PATCH 2/2] C#: Add change note. --- .../src/change-notes/2025-09-10-deprecate-foreach-capture.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 csharp/ql/src/change-notes/2025-09-10-deprecate-foreach-capture.md diff --git a/csharp/ql/src/change-notes/2025-09-10-deprecate-foreach-capture.md b/csharp/ql/src/change-notes/2025-09-10-deprecate-foreach-capture.md new file mode 100644 index 000000000000..5628e9496286 --- /dev/null +++ b/csharp/ql/src/change-notes/2025-09-10-deprecate-foreach-capture.md @@ -0,0 +1,4 @@ +--- +category: deprecated +--- +* The query `cs/captured-foreach-variable` has been deprecated as the semantics of capturing a 'foreach' variable and using it outside the loop has been stable since C# version 5.