You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VSTHRD103 does not flag sync extension method when async alternative exists in the same static class #1568
VSTHRD103 does not produce a diagnostic when calling a synchronous extension method from an async method, even though an *Async alternative is defined in the same static class and is in scope.
Repro
usingSystem.Threading.Tasks;publicinterfaceIExecutable{}publicstaticclassExecutableExtensions{publicstaticstringGetOutput(thisIExecutableexecutable)=>"";publicstaticTask<string>GetOutputAsync(thisIExecutableexecutable)=>Task.FromResult("");}classTest{asyncTaskDoWorkAsync(){IExecutableexec=null!;stringresult=exec.GetOutput();// ← No VSTHRD103 diagnostic here}}
Expected
VSTHRD103 should flag exec.GetOutput() and suggest await exec.GetOutputAsync().
Actual
No diagnostic is produced.
Notes
Both methods are extension methods on IExecutable, defined in the same static class ExecutableExtensions, with the namespace in scope via using. The analyzer does detect instance method pairs and using static scenarios per the existing test suite, but appears to miss extension method invocations using the standard obj.Method() syntax.
Discovered while converting NUnit tests from JoinableTaskFactory.Run(async () => ...) to native async Task in gitextensions/gitextensions#12987.
Activity