Add NonAwaitableTypeAttribute for MA0042/MA0045#1153
Merged
Conversation
Add a dedicated annotations attribute to configure MA0042/MA0045 await exclusions by type, wire it into await and await-using analysis, and update tests and docs accordingly. Co-authored-by: Copilot <[email protected]>
Limit NonAwaitableTypeAttribute matching to the declared type instead of its hierarchy, add regression tests for derived await/await-using cases, and document exact-type semantics. Co-authored-by: Copilot <[email protected]>
Centralize NonAwaitableTypeAttribute parsing/matching in AwaitableTypes so rules sharing awaitable detection can reuse it, and update MA0042/MA0045 to consume the shared API. Add regression coverage for MA0134 and MA0137 behavior with NonAwaitableTypeAttribute. Co-authored-by: Copilot <[email protected]>
Update MA0100, MA0134, MA0137, and MA0138 documentation to describe NonAwaitableTypeAttribute support and exact-type matching behavior. Co-authored-by: Copilot <[email protected]>
Add test coverage for NonAwaitableTypeAttribute(typeof(T<>)) so open generic declarations are validated across MA0042, MA0134, and MA0137 behaviors. Co-authored-by: Copilot <[email protected]>
Ensure each rule doc mentioning NonAwaitableTypeAttribute also references the Meziantou.Analyzer.Annotations README, following the MA0042 pattern. Co-authored-by: Copilot <[email protected]>
Adjust AwaitableTypes to evaluate only the provided type in IsNonAwaitableType, without unwrapping Task<T>/ValueTask<T>. Update rule tests to reflect task-wrapped types are no longer excluded by inner type annotations. Co-authored-by: Copilot <[email protected]>
Inline ValueTask and ValueTask generic symbol lookups directly in the constructor branch and remove temporary locals. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This was referenced May 12, 2026
Closed
Closed
This was referenced May 16, 2026
Open
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MA0042/MA0045 needed a clear attribute-based way to opt out of
awaitandawait usingrecommendations for specific types. The existingExcludeFromBlockingCallAnalysisAttributeonly targeted member-level blocking-call diagnostics and did not provide a dedicated type-level await exclusion model.What changed
NonAwaitableTypeAttributeinMeziantou.Analyzer.Annotations(assembly-level,Typeargument) and bumped the annotations package version.AwaitableTypes.ExcludeFromBlockingCallAnalysisAttribute) and type-level await exclusion (NonAwaitableTypeAttribute) as separate concepts.Fix #1152