Skip to content
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

[Engineering task] Update threading analyzers #4698

Open
pmaytak opened this issue Apr 3, 2024 · 0 comments
Open

[Engineering task] Update threading analyzers #4698

pmaytak opened this issue Apr 3, 2024 · 0 comments
Labels

Comments

@pmaytak
Copy link
Contributor

pmaytak commented Apr 3, 2024

Task type

Best practices

Description

Need to update the threading analyzers to match best practices.
https://github.com/microsoft/vs-threading/blob/main/doc/analyzers/index.md

  • Update VSTHR* rules in the editor config:
    dotnet_diagnostic.VSTHRD200.severity = error
    # Use .ConfigureAwait(bool)
    dotnet_diagnostic.VSTHRD111.severity = error
    # Avoid async void methods
    dotnet_diagnostic.VSTHRD100.severity = warning
    # Critical Threading Rules
    # Avoid legacy thread switching methods
    dotnet_diagnostic.VSTHRD001.severity = warning
    # Avoid problematic synchronous waits
    dotnet_diagnostic.VSTHRD002.severity = none
    # Avoid awaiting foreign Tasks
    dotnet_diagnostic.VSTHRD003.severity = none
    # Await SwitchToMainThreadAsync
    dotnet_diagnostic.VSTHRD004.severity = error
    # Invoke single-threaded types on Main thread
    dotnet_diagnostic.VSTHRD010.severity = warning
    # Use AsyncLazy<T>
    dotnet_diagnostic.VSTHRD011.severity = none #error requires the use of Microsoft.VisualStudio.Threading to get access to the AsyncLazy<T> type
    # Provide JoinableTaskFactory where allowed
    dotnet_diagnostic.VSTHRD012.severity = warning
    # Compiler warnings that trigger SDL
    dotnet_diagnostic.CS0618.severity = error
    # General Threading Rules
    # VSTHRD103: Call async methods when in an async method
    dotnet_diagnostic.VSTHRD103.severity = none
    # VSTHRD105: use current context
    dotnet_diagnostic.VSTHRD105.severity = none
    # VSTHRD001: use JoinableTaskFactory (this is part of a different package - MSAL cannot use it)
    dotnet_diagnostic.VSTHRD001.severity = none
  • Remove this rule from tests .editorconfig:
    dotnet_diagnostic.VSTHRD100.severity = none
  • Suppress any other irrelevant rules in tests .editorconfig.
  • Fix any errors or suppress them in the GlobalSuppressions file.
  • Ignore all the rules for json folder.

See some work done in pmaytak/threading-analyzers.

Solution

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Committed
Development

No branches or pull requests

1 participant