C#: Property- and Indexer call targets for partial overrides.#21881
Open
michaelnebel wants to merge 5 commits into
Open
C#: Property- and Indexer call targets for partial overrides.#21881michaelnebel wants to merge 5 commits into
michaelnebel wants to merge 5 commits into
Conversation
7f38b80 to
b36175b
Compare
… apply to only a getter or a setter).
b36175b to
0a0867a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Improves C# call target resolution for property and indexer accesses when only one accessor (getter or setter) is overridden, and adjusts call-target quality telemetry to exclude delegate-like calls (including function pointer calls) from “missing target” reporting.
Changes:
- Add property/indexer accessor “read/write target” resolution that follows override chains to find the effective getter/setter.
- Update call-target telemetry filtering to exclude
DelegateLikeCallrather than onlyDelegateCall. - Extend C# library tests (source + expected outputs) and add a change note covering the behavior change.
Show a summary per file
| File | Description |
|---|---|
| csharp/ql/test/library-tests/properties/Properties19.expected | Updates expected call-target results to include correct getter/setter targets for partially overridden properties. |
| csharp/ql/test/library-tests/properties/Properties17.expected | Updates expected field list to include the synthesized Value.field. |
| csharp/ql/test/library-tests/properties/properties.cs | Adds a new test scenario covering partial property overrides (getter-only override) and observed call targets. |
| csharp/ql/test/library-tests/properties/PrintAst.expected | Updates AST expectations for the newly added test classes and property calls. |
| csharp/ql/src/Telemetry/DatabaseQuality.qll | Excludes DelegateLikeCall from missing-call-target telemetry classification. |
| csharp/ql/lib/semmle/code/csharp/Property.qll | Adds accessor target resolution helpers for read/write contexts across override chains. |
| csharp/ql/lib/semmle/code/csharp/exprs/Call.qll | Routes PropertyCall/IndexerCall target resolution through the new property/indexer read/write target logic. |
| csharp/ql/lib/change-notes/2026-05-22-property-indexer-partial-override.md | Documents the analysis improvement as a minor analysis change. |
Copilot's findings
- Files reviewed: 8/8 changed files
- Comments generated: 0
Contributor
Author
|
DCA looks good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It appears that call targets for properties and indexers are missing, when only the getter or setter is overridden.
Assume we have
For the example below, we extract an access to the property
ValuefromDerivedClass1. However, only the getter is overridden, which means that the setter being called is the one fromBaseClass.Furthermore, the function pointer calls are removed from the set of calls where we are interested in reporting missing call targets (as the class of function pointer calls explicitly overrides the
getTargetpredicate withnone()).