Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C#: Improvecs/dereference-* queries and add to the Code Quality suite.#19589

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
michaelnebel merged 8 commits intogithub:mainfrommichaelnebel:csharp/dereference
Jun 11, 2025

Conversation

michaelnebel
Copy link
Contributor

@michaelnebelmichaelnebel commentedMay 27, 2025
edited
Loading

In this PR we do the following forcs/dereferenced-value-is-always-null andcs/dereferenced-value-may-be-null.

  • Change the class of de-referenced expressions: When calling a library extension method where thethis parameter is a nullable type, we now assume that the null may happen in the extension method itself (this is at least common for the usage of testing frameworks, which reports a high amount of false positives related to the use of such extension methods).
  • Remove the explicit type requirements on Debug.Assert methods (they are trivially true). They cause issues when extraction have broken types - and the change doesn't affect the methods that match the predicate when types are healthy.
  • Add the queries of the Code Quality suite.
  • Convert the tests to use inline expectations tests.

DCA looks good.

@michaelnebelmichaelnebelforce-pushed thecsharp/dereference branch 2 times, most recently fromc1e05e6 to09f9849CompareMay 27, 2025 12:17
@michaelnebelmichaelnebel marked this pull request as ready for reviewJune 4, 2025 08:15
@CopilotCopilotAI review requested due to automatic review settingsJune 4, 2025 08:15
@michaelnebelmichaelnebel requested a review froma team as acode ownerJune 4, 2025 08:15
Copy link
Contributor

@CopilotCopilotAI left a comment

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 enhances the null-dereference queries by treating nullable extension-method receivers as potentially safe, removes strict type checks onDebug.Assert, and folds the new queries into the Code Quality suite with inline-expectation tests.

  • Broadencs/dereferenced-value-is-always-null/cs/dereferenced-value-may-be-null to ignore null dereferences inside library extension methods on nullable receivers.
  • Simplify Debug.Assert matching by dropping parameter-type checks.
  • Add both queries to the Code Quality query suite and convert tests to use inline expectations.

Reviewed Changes

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

FileDescription
csharp/ql/src/change-notes/2025-06-03-dereferece-extension-method.mdAdds change note for extension-method deref behavior (typo in name)
csharp/ql/lib/semmle/code/csharp/frameworks/system/Diagnostics.qllLoosenAssert matcher to anyAssert overload without param check
csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qllUpdateDereference predicate to treat nullable extension receivers safely
csharp/ql/integration-tests/posix/query-suite/csharp-code-quality.qls.expectedInclude the new queries in the Code Quality suite

Copy link
Contributor

@hvitvedhvitved left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@michaelnebelmichaelnebel merged commitf038e2f intogithub:mainJun 11, 2025
25 checks passed
@michaelnebelmichaelnebel deleted the csharp/dereference branchJune 11, 2025 11:41
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@hvitvedhvitvedhvitved approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@michaelnebel@hvitved

[8]ページ先頭

©2009-2025 Movatter.jp