Skip to content

Add DoNotUseThreadSleepAnalyzer to warn against Thread.Sleep in async…#304

Merged
SergeyTeplyakov merged 1 commit intomasterfrom
dev/thread_sleep
Jun 29, 2025
Merged

Add DoNotUseThreadSleepAnalyzer to warn against Thread.Sleep in async…#304
SergeyTeplyakov merged 1 commit intomasterfrom
dev/thread_sleep

Conversation

@SergeyTeplyakov
Copy link
Copy Markdown
Owner

… methods

@SergeyTeplyakov SergeyTeplyakov requested a review from Copilot June 29, 2025 16:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new analyzer to flag uses of Thread.Sleep inside asynchronous contexts.

  • Adds a diagnostic descriptor (EPC33) to DiagnosticDescriptors
  • Implements DoNotUseThreadSleepAnalyzer and supporting extension methods
  • Updates tests and release notes for the new rule

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ErrorProne.NET.CoreAnalyzers/DiagnosticDescriptors.cs Declares a new EPC33 descriptor for banning Thread.Sleep in async methods
src/ErrorProne.NET.CoreAnalyzers/CompilationExtensions.cs Adds FindEnclosingMethodSymbol and FindParentLocalOrLambdaSymbol extensions
src/ErrorProne.NET.CoreAnalyzers/AsyncAnalyzers/DoNotUseThreadSleepAnalyzer.cs Implements the analyzer logic and registers the rule
src/ErrorProne.NET.CoreAnalyzers/AnalyzerReleases.Unshipped.md Documents the new EPC33 entry in release notes
src/ErrorProne.NET.CoreAnalyzers.Tests/AsyncAnalyzers/DoNotUseThreadSleepAnalyzerTests.cs Adds comprehensive tests covering async methods, lambdas, and local functions
Comments suppressed due to low confidence (1)

src/ErrorProne.NET.CoreAnalyzers/AsyncAnalyzers/DoNotUseThreadSleepAnalyzer.cs:19

  • The collection expression '[Rule]' does not correctly initialize an ImmutableArray. Use ImmutableArray.Create(Rule) or ImmutableArray.CreateRange(new[] { Rule }) instead.
        public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Rule];

@SergeyTeplyakov SergeyTeplyakov merged commit 2f44856 into master Jun 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants