VSTHRD100 detects async void local functions and lamdas - #1075
Conversation
7b3b072 to
de49f1f
Compare
|
I cannot reproduce the CI test failures locally. I suspect the compiler version is at play here. |
|
|
||
| class Test { | ||
| void M() { | ||
| F(async void () => await Task.Delay(0)); |
There was a problem hiding this comment.
This is invalid syntax, and the cause for the test failure in CI. You mentioned you couldn't repro it locally, but that really surprises me, since it isn't valid in any version of the language or compiler AFAIK. Even Sharplab shows this failing.
If you just remove the void modifier (which lambdas aren't allowed to specify), it works.
There was a problem hiding this comment.
In C# 10 it's possible to specify the return type of a lambda in code:
That Sharplab code works if you set the compiler to main and the output to something other than ASM:
I think the problem in this case is the version of the compiler being used differs in CI from what I have locally (int.main).
Removing the explicit return type is fine however, as it's optional in that case.
There was a problem hiding this comment.
Very strange, and disappointing that the tests aren't effectively pinning whatever versions vary between our official builds and your local build. We are pinning the compiler. I would have thought the langversion was effectively pinned as well.
|
Andrew Arnott (@AArnott) would you expect this in 17.4.10-alpha? I just tried pulling it down and don't see diagnostics on async void local functions. |
|
Your change only went into 17.4.14-alpha. |
|
We only push packages to the feed you found 17.4.10-alpha nightly. |

Fixes #1074