VSTHRD104 should not fire for extension methods wrapping async methods
Bug description
VSTHRD104 claims: "Expose an async version of this method that does not synchronously block. Then simplify this method to call that async method within a JoinableTaskFactory.Run delegate."
I did exactly this, exposing the async methods on an interface, and the synchroneous method added via extension methods (so not all implementations need to provide their own implementation).
However, now VSTHRD104 fires on just those extension methods.
Repro steps
public interface IMessagePoolRemoteRpcService
{
Task ClearStatusPoolAsync(string category);
}
public static class SyncRemoteMessagePoolExtensions
{
private static readonly JoinableTaskFactory Jtf = new(new JoinableTaskContext());
// VSTHRD104 fires here...
public static void ClearStatusPool(this IMessagePoolRemoteRpcService service, string category)
=> Jtf.Run(() => service.ClearStatusPoolAsync(category));
}
Expected behavior
I don't expect VSTHRD104 to trigger on a method which just implements the the pattern suggested by the same analyzer.
Actual behavior
I get a warning of VSTHRD104 on the static extension method I created to implement the suggestion of just the same rule.
- Version used: Microsoft.VisualStudio.Threading.Analyzers 17.6.40, indirectly referenced via Microsoft.VisualStudio.Threading
- Application (if applicable):
Additional context
Add any other context about the problem here.
Your scenario here seems valid. I'm not sure when we'll have time to fix this. If you'd care to submit a PR with a regression test, I'd be happy to review and merge it.