Skip to content

Conversation

@SergeyTeplyakov
Copy link
Owner

Introduces analyzer EPC37 to detect argument validation in public async methods, which can cause exceptions to be thrown only when the returned Task is awaited. Adds documentation, analyzer implementation, tests, and diagnostic descriptor for EPC37. Updates ReadMe and analyzer release notes accordingly.

Introduces analyzer EPC37 to detect argument validation in public async methods, which can cause exceptions to be thrown only when the returned Task is awaited. Adds documentation, analyzer implementation, tests, and diagnostic descriptor for EPC37. Updates ReadMe and analyzer release notes accordingly.
@SergeyTeplyakov SergeyTeplyakov requested a review from Copilot July 2, 2025 18:15
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 (EPC37) that warns when public async methods perform argument validation by throwing exceptions, which delays failures until the returned Task is awaited. Also includes descriptor, tests, docs, and a small test harness update to support specifying language version.

  • Introduce DoNotValidateArgumentsInAsyncMethodsAnalyzer with logic to catch throws and validation invocations in async methods
  • Add EPC37 diagnostic descriptor, tests, documentation, and release notes
  • Extend test verifier to accept an optional LanguageVersion parameter

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/RoslynNunitTestRunner/CSharpCodeFixVerifier`2+Test.cs Added LanguageVersion overload and updated test initialization
src/ErrorProne.NET.CoreAnalyzers/DiagnosticDescriptors.cs Added descriptor EPC37
src/ErrorProne.NET.CoreAnalyzers/AsyncAnalyzers/DoNotValidateArgumentsInAsyncMethodsAnalyzer.cs New analyzer implementation for EPC37
src/ErrorProne.NET.CoreAnalyzers/AnalyzerReleases.Unshipped.md Registered EPC37 in unshipped release notes
src/ErrorProne.NET.CoreAnalyzers.Tests/AsyncAnalyzers/DoNotValidateArgumentsInAsyncMethodsAnalyzerTests.cs Added comprehensive tests for EPC37
docs/Rules/EPC37.md Documentation and examples for EPC37
ReadMe.md Updated rule tables to include EPC37 and adjust EPC20 grouping

Replaces a single-line return statement with an explicit if block for checking exception type names. This change improves readability and prepares for potential future extensions.
@SergeyTeplyakov SergeyTeplyakov merged commit 3fec13e into master Jul 2, 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