Skip to content

C#: Deprecate cs/captured-foreach-variable. - #20401

Merged
michaelnebel merged 2 commits into
github:mainfrom
michaelnebel:csharp/deprecatecapturedforeachvariable
Sep 11, 2025
Merged

C#: Deprecate cs/captured-foreach-variable.#20401
michaelnebel merged 2 commits into
github:mainfrom
michaelnebel:csharp/deprecatecapturedforeachvariable

Conversation

@michaelnebel

Copy link
Copy Markdown
Contributor

No description provided.

@michaelnebel
michaelnebelforce-pushed the csharp/deprecatecapturedforeachvariable branch from 21e98ca to 186e42bCompareSeptember 10, 2025 12:04
@michaelnebel
michaelnebel marked this pull request as ready for review September 10, 2025 12:25
@michaelnebel
michaelnebel requested a review from a team as a code ownerSeptember 10, 2025 12:25
CopilotAI review requested due to automatic review settings September 10, 2025 12:25

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR deprecates the C# query cs/captured-foreach-variable which detected issues with capturing foreach variables in lambdas. The deprecation is warranted since C# version 5 stabilized the semantics of capturing foreach variables, making this query obsolete for modern C# development.

Key changes:

  • Added deprecation documentation explaining the rationale
  • Marked the query as deprecated with appropriate JSDoc annotation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

FileDescription
csharp/ql/src/change-notes/2025-09-10-deprecate-foreach-capture.mdDocuments the deprecation of the foreach capture query
csharp/ql/src/Language Abuse/ForeachCapture.qlAdds @deprecated annotation to the query header

@michaelnebelmichaelnebel changed the title C#: Add change note.C#: Deprecate cs/captured-foreach-variable.Sep 10, 2025
@michaelnebel
michaelnebel merged commit 0b43203 into github:mainSep 11, 2025
24 checks passed
@michaelnebel
michaelnebel deleted the csharp/deprecatecapturedforeachvariable branch September 11, 2025 13:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@michaelnebel@hvitved