C#: Add flow summary for 'Task.ConfigureAwait()'#4543
Conversation
tamasvajk
left a comment
There was a problem hiding this comment.
Let's suppose the AccessPath::cons is working. How would I verify that the added flow summaries are working for the following two cases?
var i = new Task<int>(() => 42).ConfigureAwait(false).GetAwaiter().GetResult();
var j = await new Task<int>(() => 42).ConfigureAwait(false);
This question is actually not specific to .ConfigureAwait(). Which checks rely on flow summaries on .GetAwaiter().GetResult()?
| m = this.getConfigureAwaitMethod() and | ||
| source = TCallableFlowSourceQualifier() and | ||
| sourceAp = AccessPath::empty() and | ||
| sink = TCallableFlowSinkReturn() and | ||
| sinkAp = | ||
| AccessPath::cons(any(FieldContent fc | | ||
| fc.getField() = | ||
| any(SystemRuntimeCompilerServicesConfiguredTaskAwaitableTStruct t) | ||
| .getUnderlyingAwaiterField() | ||
| ), | ||
| AccessPath::field(any(SystemRuntimeCompilerServicesConfiguredTaskAwaitableTConfiguredTaskAwaiterStruct s | ||
| ).getUnderlyingTaskField())) | ||
| } |
There was a problem hiding this comment.
@hvitved This is missing from the test expected file.
When I try to debug this on a codeql database create DB with the following:
private predicate test(
SystemRuntimeCompilerServicesConfiguredTaskAwaitableTConfiguredTaskAwaiterStruct a, Field f
) {
a.getAField() = f
}
I only get two fields: _dummy and _dummyPrimitive, and therefore I get no fields in .getUnderlyingTaskField(). It looks to me that Roslyn reports these field names.
- What is the difference between the test and a
codeql database createextraction? - How do I extract the correct field names with
codeql database create? - Why doesn't this
AccessPath::conswork?
145a01c to
03a3676
Compare
|
@hvitved The only change I did since your fix is that I've squashed the first two commits. |
| } | ||
| } | ||
|
|
||
| /** An unbound generic struct in the `System.Runtime.CompilerServices` namespace. */ |
There was a problem hiding this comment.
This comment is not correct. I think this class is so special that there is no need to have it, instead inline the logic where it is used below.
No description provided.