C#: Convert System.Collections.Generic.KeyValuePair flow to CSV format.

This commit is contained in:
Michael Nebel 2021-12-09 14:27:18 +01:00
Родитель 42bf866fb3
Коммит 679aad138e
2 изменённых файлов: 12 добавлений и 21 удалений

Просмотреть файл

@ -1330,27 +1330,6 @@ class IDictionaryFlow extends LibraryTypeDataFlow, RefType {
}
}
/** Data flow for `System.Collections.Generic.KeyValuePair`. */
class SystemCollectionsGenericKeyValuePairStructFlow extends LibraryTypeDataFlow,
SystemCollectionsGenericKeyValuePairStruct {
override predicate callableFlow(
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
SourceDeclarationCallable c, boolean preservesValue
) {
preservesValue = true and
exists(int i |
c.(Constructor).getDeclaringType() = this and
source = TCallableFlowSourceArg(i) and
sourceAp = AccessPath::empty() and
sink = TCallableFlowSinkReturn()
|
i = 0 and sinkAp = AccessPath::property(this.getKeyProperty())
or
i = 1 and sinkAp = AccessPath::property(this.getValueProperty())
)
}
}
/** Data flow for `System.[Value]Tuple<,...,>`. */
class SystemTupleFlow extends LibraryTypeDataFlow, ValueOrRefType {
SystemTupleFlow() {

Просмотреть файл

@ -2,6 +2,7 @@
import csharp
private import semmle.code.csharp.frameworks.system.Collections
private import semmle.code.csharp.dataflow.ExternalFlow
/** The `System.Collections.Generic` namespace. */
class SystemCollectionsGenericNamespace extends Namespace {
@ -123,6 +124,17 @@ class SystemCollectionsGenericKeyValuePairStruct extends SystemCollectionsGeneri
}
}
/** Data flow for `System.Collections.Generic.KeyValuePair`. */
private class SystemCollectionsGenericKeyValuePairStructFlowModelCsv extends SummaryModelCsv {
override predicate row(string row) {
row =
[
"System.Collections.Generic;KeyValuePair<,>;false;KeyValuePair;(TKey,TValue);;Argument[0];Property[System.Collections.Generic.KeyValuePair<,>.Key] of ReturnValue;value",
"System.Collections.Generic;KeyValuePair<,>;false;KeyValuePair;(TKey,TValue);;Argument[1];Property[System.Collections.Generic.KeyValuePair<,>.Value] of ReturnValue;value"
]
}
}
/** The `System.Collections.Generic.ICollection<>` interface. */
class SystemCollectionsGenericICollectionInterface extends SystemCollectionsGenericUnboundGenericInterface {
SystemCollectionsGenericICollectionInterface() { this.hasName("ICollection<>") }