Skip to content

Add NonAsyncDisposableTypeAttribute for await using#1154

Merged
meziantou merged 4 commits into
mainfrom
meziantou/await-using-attribute
May 12, 2026
Merged

Add NonAsyncDisposableTypeAttribute for await using#1154
meziantou merged 4 commits into
mainfrom
meziantou/await-using-attribute

Conversation

@meziantou
Copy link
Copy Markdown
Owner

@meziantou meziantou commented May 12, 2026

NonAwaitableTypeAttribute was suppressing both await and await using recommendations, which made it impossible to opt out of only await using guidance. This change separates those concerns so projects can configure each behavior independently.

What changed

  • Added NonAsyncDisposableTypeAttribute in Meziantou.Analyzer.Annotations for await using suppression.
  • Updated MA0042/MA0045 await-using analysis to honor only NonAsyncDisposableTypeAttribute.
  • Kept NonAwaitableTypeAttribute for awaitability checks (await) only.
  • Updated analyzer internals to detect both attributes separately.
  • Updated tests in async and non-async MA0042 suites to lock the new behavior.
  • Updated documentation for MA0042, MA0045, and annotations README.
  • Bumped Meziantou.Analyzer.Annotations version to 1.5.0.

Notes for reviewers

This intentionally changes behavior: existing projects that used NonAwaitableTypeAttribute to suppress await using diagnostics now need to use NonAsyncDisposableTypeAttribute.

Fix #1152

@meziantou meziantou merged commit bdc4841 into main May 12, 2026
13 checks passed
@meziantou meziantou deleted the meziantou/await-using-attribute branch May 12, 2026 20:41
This was referenced May 12, 2026
This was referenced May 16, 2026
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.

ExcludeFromBlockingCallAnalysisAttribute not working as expected

1 participant