mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
C#: Include store steps into readonly properties.
This commit is contained in:
@@ -127,6 +127,13 @@ class Property extends DotNet::Property, DeclarationWithGetSetAccessors, @proper
|
||||
properties(this, _, _, getTypeRef(result), _)
|
||||
}
|
||||
|
||||
private predicate isAutoPartial() {
|
||||
this.fromSource() and
|
||||
not this.isExtern() and
|
||||
not this.isAbstract() and
|
||||
not this.getAnAccessor().hasBody()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this property is automatically implemented. For example, `P1`
|
||||
* on line 2 is automatically implemented, while `P2` on line 5 is not in
|
||||
@@ -147,11 +154,22 @@ class Property extends DotNet::Property, DeclarationWithGetSetAccessors, @proper
|
||||
* code.
|
||||
*/
|
||||
predicate isAutoImplemented() {
|
||||
this.fromSource() and
|
||||
this.isReadWrite() and
|
||||
not this.isExtern() and
|
||||
not this.isAbstract() and
|
||||
not this.getAnAccessor().hasBody()
|
||||
this.isAutoPartial() and
|
||||
this.isReadWrite()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this property is automatically implemented and read-only. For
|
||||
* example, `P1` on line 2 is automatically implemented and read-only
|
||||
* ```csharp
|
||||
* class C {
|
||||
* public int P1 { get; }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
predicate isAutoImplementedReadOnly() {
|
||||
this.isAutoPartial() and
|
||||
this.isReadOnly()
|
||||
}
|
||||
|
||||
override Property getUnboundDeclaration() { properties(this, _, _, _, result) }
|
||||
|
||||
@@ -1899,6 +1899,8 @@ class FieldOrProperty extends Assignable, Modifiable {
|
||||
(
|
||||
p.isAutoImplemented()
|
||||
or
|
||||
p.isAutoImplementedReadOnly()
|
||||
or
|
||||
p.matchesHandle(any(CIL::TrivialProperty tp))
|
||||
or
|
||||
p.getDeclaringType() instanceof AnonymousClass
|
||||
|
||||
Reference in New Issue
Block a user