New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VSTHRD002 code fix throws NRE when compile errors are present #454
Comments
I'm getting using System;
using System.Threading;
using System.Threading.Tasks;
namespace TestAsyncAnalyzers
{
class Program
{
static void Main(string[] args)
{
DoSomething(default);
Console.WriteLine("Hello World!");
}
void DoSomething(CancellationToken cancellationToken)
{
Thread.Sleep(1);
Task.Delay(2, cancellationToken).Wait(cancellationToken); // <<-------- Execute code fix here
}
}
} Current behavior:
|
Also occurs in Microsoft Visual Studio 2022 (64-bit) Version 17.1.1
Microsoft.VisualStudio.Threading.Analyzers 17.0.64 |
This also triggered when opening a solution for the first time with the analyzer installed. Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.4.3
|
while trying to use the code fixer "use await instead" the same error/stacktrace is observed.
|
Bug description
VSTHRD002 code fix provider throws NRE when activated on a diagnostic with a compile error for one of the arguments.
Repro steps
I had this method, which violated VSTHRD002. Note that there is no
using System.Threading;
line for this file, soCancellationToken.None
did not resolve when I activated the light bulb to look at code fixes.Expected behavior
The code fix is not offered, or works.
Actual behavior
Additional context
This happened while working in the
MessagePack-CSharp
repo,fix9
branch.The text was updated successfully, but these errors were encountered: