microsoft / microsoft/vs-threading

VSTHRD200 should be able to have method type configured

Open
#1,327 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

analyzers
Dominant language
C#
Stars
1k
Forks
160
Avg merge
1d 12h
Merged PRs (30d)
28

Description

Is your feature request related to a problem? Please describe.

This analyzer reports all instances of this condition. There are different schools of thought about requiring an Async suffix on awaitable methods.

  • Always, all the time (or not at all) -- these are the only current options
  • Only on public methods
  • Only on methods that also have non-awaitable methods
  • Only on non-private methods (my preference)
  • Combinations of the above
Describe the solution you'd like

I'd like to see .editorconfig settings to modify the behavior of this analyzer.
dotnet_diagnostic.VSTHRD200.allowed_exceptions = private, internal, protected, no_non_async

Whether it takes this exact form doesn't matter. I just want to shut this warning up for private methods.

Describe alternatives you've considered

I can silence all instances of this analyzer, silence it by file, live with warnings, or follow rules that we don't agree with.

Additional context

I use source generators for binding methods to a view, and the "fix" functionality renames methods but not the generated reference to them in XAML. So this:

private async Task AddStation() { }

which is generated as

public global::CommunityToolkit.Mvvm.Input.IRelayCommand DeleteUserCommand => deleteUserCommand ??= new global::CommunityToolkit.Mvvm.Input.RelayCommand(new global::System.Action(DeleteUser), () => CanDeleteUser);

would be DeleteUserAsyncCommand, and I would have to go through all of my XAML views and fix it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the VSTHRD200 analyzer entry point and inspect how its current all-or-nothing behavior is implemented. Define the supported method-type combinations and their .editorconfig representation, then verify that private-method exceptions and the existing behavior are covered by the analyzer's tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.