Skip to content

Commit 034d45d

Browse files
committed
C#: Convert System.Threading.Tasks.TaskFactory flow to CSV format.
1 parent 440976f commit 034d45d

File tree

2 files changed

+102
-81
lines changed

2 files changed

+102
-81
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,87 +1410,6 @@ private class SystemRuntimeCompilerServicesConfiguredTaskAwaitableTFlow extends
14101410
}
14111411
}
14121412

1413-
/** Data flow for `System.Threading.Tasks.TaskFactory`(`<TResult>`). */
1414-
class SystemThreadingTasksFactoryFlow extends LibraryTypeDataFlow {
1415-
SystemThreadingTasksFactoryFlow() {
1416-
this instanceof SystemThreadingTasksClass and
1417-
this.getName().regexpMatch("TaskFactory(<>)?")
1418-
}
1419-
1420-
override predicate callableFlow(
1421-
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
1422-
SourceDeclarationCallable c, boolean preservesValue
1423-
) {
1424-
this.methodFlow(source, sourceAp, sink, sinkAp, c) and
1425-
preservesValue = true
1426-
}
1427-
1428-
private predicate methodFlow(
1429-
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
1430-
SourceDeclarationMethod m
1431-
) {
1432-
m.getDeclaringType() = this and
1433-
(
1434-
m.getUndecoratedName().regexpMatch("ContinueWhen(All|Any)") and
1435-
(
1436-
// flow into supplied function
1437-
exists(ConstructedDelegateType delegate, ArrayType at, int i, int j, int k |
1438-
at = m.getParameter(i).getType() and
1439-
at.getElementType() = any(SystemThreadingTasksTaskTClass c).getAConstructedGeneric() and
1440-
(at = delegate.getTypeArgument(k) or at.getElementType() = delegate.getTypeArgument(k)) and
1441-
m.getParameter(j).getType() = delegate and
1442-
(
1443-
delegate.getUnboundGeneric() instanceof SystemActionTDelegateType or
1444-
delegate.getUnboundGeneric() instanceof SystemFuncDelegateType
1445-
) and
1446-
source = TCallableFlowSourceArg(i) and
1447-
sourceAp = AccessPath::empty() and
1448-
sink = getDelegateFlowSinkArg(m, j, k) and
1449-
sinkAp = AccessPath::empty()
1450-
)
1451-
or
1452-
// flow out of supplied function
1453-
exists(ConstructedDelegateType func, int i |
1454-
m.getParameter(i).getType() = func and
1455-
func.getUnboundGeneric() instanceof SystemFuncDelegateType and
1456-
source = getDelegateFlowSourceArg(m, i) and
1457-
sourceAp = AccessPath::empty() and
1458-
sink = TCallableFlowSinkReturn() and
1459-
sinkAp = AccessPath::property(any(SystemThreadingTasksTaskTClass c).getResultProperty())
1460-
)
1461-
)
1462-
or
1463-
m.hasUndecoratedName("StartNew") and
1464-
(
1465-
// flow from supplied state to supplied delegate
1466-
exists(ConstructedDelegateType delegate, int i, int j, int k |
1467-
m.getParameter(i).getType() instanceof ObjectType and
1468-
m.getParameter(j).getType() = delegate and
1469-
(
1470-
delegate.getUnboundGeneric() instanceof SystemActionTDelegateType or
1471-
delegate.getUnboundGeneric() instanceof SystemFuncDelegateType
1472-
) and
1473-
delegate.getTypeArgument(k) instanceof ObjectType and
1474-
source = TCallableFlowSourceArg(i) and
1475-
sourceAp = AccessPath::empty() and
1476-
sink = getDelegateFlowSinkArg(m, j, k) and
1477-
sinkAp = AccessPath::empty()
1478-
)
1479-
or
1480-
// flow out of supplied function
1481-
exists(ConstructedDelegateType func, int i |
1482-
m.getParameter(i).getType() = func and
1483-
func.getUnboundGeneric() instanceof SystemFuncDelegateType and
1484-
source = getDelegateFlowSourceArg(m, i) and
1485-
sourceAp = AccessPath::empty() and
1486-
sink = TCallableFlowSinkReturn() and
1487-
sinkAp = AccessPath::property(any(SystemThreadingTasksTaskTClass c).getResultProperty())
1488-
)
1489-
)
1490-
)
1491-
}
1492-
}
1493-
14941413
/** Data flow for `System.Runtime.CompilerServices.TaskAwaiter<>`. */
14951414
class SystemRuntimeCompilerServicesTaskAwaiterFlow extends LibraryTypeDataFlow,
14961415
SystemRuntimeCompilerServicesTaskAwaiterStruct {

0 commit comments

Comments
 (0)