Skip to content

Commit 5434504

Browse files
committed
C#: Consider properties that has any auto declaration as an auto property in terms of field store.
1 parent dde28a1 commit 5434504

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,16 @@ class CaptureNode extends NodeImpl, TCaptureNode {
20802080
override string toStringImpl() { result = cn.toString() }
20812081
}
20822082

2083+
/**
2084+
* Holds if a property has accessors declared in multiple locations, and where
2085+
* all accessors have at least one declaration without a body.
2086+
* This can happen if both a "real" and a "stub" implementation is included in the
2087+
* same database (which is the case for .NET Runtime).
2088+
*/
2089+
private predicate hasAutoImplementation(Property p) {
2090+
forall(Accessor a | a = p.getAnAccessor() | count(getASourceLocation(a)) > count(a.getBody()))
2091+
}
2092+
20832093
/** A field or a property. */
20842094
class FieldOrProperty extends Assignable, Modifiable {
20852095
FieldOrProperty() {
@@ -2100,6 +2110,8 @@ class FieldOrProperty extends Assignable, Modifiable {
21002110
p.isAutoImplementedReadOnly()
21012111
or
21022112
p.getDeclaringType() instanceof AnonymousClass
2113+
or
2114+
hasAutoImplementation(p)
21032115
)
21042116
or
21052117
p.fromLibrary()

0 commit comments

Comments
 (0)