Skip to content

Conversation

@SergeyTeplyakov
Copy link
Owner

Introduces EPC36, which warns when async delegates are used with Task.Factory.StartNew and TaskCreationOptions.LongRunning. Adds analyzer implementation, tests, documentation, and diagnostic descriptor. This helps prevent inefficient use of threads and clarifies intent when working with async code.

Introduces EPC36, which warns when async delegates are used with Task.Factory.StartNew and TaskCreationOptions.LongRunning. Adds analyzer implementation, tests, documentation, and diagnostic descriptor. This helps prevent inefficient use of threads and clarifies intent when working with async code.
@SergeyTeplyakov SergeyTeplyakov requested a review from Copilot July 1, 2025 22:34
Copy link
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

Adds a new analyzer (EPC36) that warns when async delegates are used with Task.Factory.StartNew combined with TaskCreationOptions.LongRunning, to prevent inefficient thread usage and clarify intent in async code.

  • Introduces DiagnosticDescriptor EPC36 in DiagnosticDescriptors.cs.
  • Implements analyzer logic in DoNotUseAsyncDelegatesForLongRunningTasksAnalyzer.cs, along with unit tests.
  • Updates release notes and adds documentation for the new rule.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ErrorProne.NET.CoreAnalyzers/DiagnosticDescriptors.cs Added EPC36 diagnostic descriptor for async delegates with LongRunning
src/ErrorProne.NET.CoreAnalyzers/AsyncAnalyzers/DoNotUseAsyncDelegatesForLongRunningTasksAnalyzer.cs Implemented analyzer logic to detect async delegates in StartNew calls with LongRunning
src/ErrorProne.NET.CoreAnalyzers/AnalyzerReleases.Unshipped.md Included EPC36 in the list of pending analyzer releases
src/ErrorProne.NET.CoreAnalyzers.Tests/AsyncAnalyzers/DoNotUseAsyncDelegatesForLongRunningTasksAnalyzerTests.cs Added comprehensive tests covering correct and incorrect scenarios
docs/Rules/EPC36.md Created documentation with examples and guidance for EPC36
Comments suppressed due to low confidence (1)

docs/Rules/EPC36.md:10

  • The ordered list numbering jumps from 1 to 3. Renumber this item as '2.' to maintain correct sequence.
3. **Creating confusion**: The intent of the code becomes unclear - is it meant to be long-running synchronous work or efficient async work? Is it really the case that the synchronous block of the async method is taking a long time, or it's just a mistake?

@SergeyTeplyakov SergeyTeplyakov merged commit 914c10f into master Jul 1, 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