Skip to content

Commit 0a39e8c

Browse files
authored
Merge pull request #905 from calumgrant/cs/trivial-cil-properties
C#: Use CIL analysis when determining trivial properties
2 parents 92ba091 + 65b3771 commit 0a39e8c

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

change-notes/1.20/analysis-csharp.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626

2727
## Changes to QL libraries
2828

29+
* The class `TrivialProperty` now includes library properties determined to be trivial using CIL analysis. This may increase the number of results for all queries that use data flow.
30+
2931
## Changes to the autobuilder

csharp/ql/src/semmle/code/csharp/Property.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Member
77
import Stmt
88
private import semmle.code.csharp.ExprOrStmtParent
99
private import dotnet
10+
private import cil
1011

1112
/**
1213
* A declaration that may have accessors. Either an event (`Event`), a property
@@ -495,6 +496,8 @@ class TrivialProperty extends Property {
495496
isAutoImplemented()
496497
or
497498
getGetter().trivialGetterField() = getSetter().trivialSetterField()
499+
or
500+
exists(CIL::TrivialProperty prop | this.matchesHandle(prop))
498501
}
499502
}
500503

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| System.Collections.DictionaryEntry.Key |
2+
| System.Collections.DictionaryEntry.Value |
3+
| System.Reflection.AssemblyName.CodeBase |
4+
| System.Reflection.AssemblyName.CultureInfo |
5+
| System.Reflection.AssemblyName.HashAlgorithm |
6+
| System.Reflection.AssemblyName.KeyPair |
7+
| System.Reflection.AssemblyName.Name |
8+
| System.Reflection.AssemblyName.Version |
9+
| System.Reflection.AssemblyName.VersionCompatibility |
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import csharp
2+
3+
from TrivialProperty prop
4+
where
5+
prop.getDeclaringType().hasQualifiedName("System.Reflection.AssemblyName")
6+
or
7+
prop.getDeclaringType().hasQualifiedName("System.Collections.DictionaryEntry")
8+
select prop.getQualifiedName()

0 commit comments

Comments
 (0)