Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSTHRD003 analyzer false positive fixes #1258

Merged
merged 3 commits into from Nov 17, 2023
Merged

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Nov 16, 2023

This pull request to the Microsoft.VisualStudio.Threading.Analyzers.CSharp codebase includes modifications to the AnalyzeAwaitExpression method to support returning members of a parameter in a lambda, as well as new tests to verify that warnings are not reported in specific scenarios involving awaiting task properties and returning tasks from lambda arguments.

Main changes:

  • src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/VSTHRD003UseJtfRunAsyncAnalyzer.cs: Modified the AnalyzeAwaitExpression method to allow returning members of a parameter in a lambda.
  • test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD003UseJtfRunAsyncAnalyzerTests.cs: Added three new tests to verify that warnings are not reported in specific scenarios involving awaiting task properties and returning tasks from lambda arguments. [1] [2] [3]

Testing improvements:

  • test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier``2+Test.cs: Updated CreateParseOptions method in CSharpCodeFixVerifier to set language version to CSharp11.

…ect returned from an invocation

We assume that the method is returning something fresh, such that the accessed Task belongs to the caller's context.
@AArnott AArnott merged commit 8aaa7b8 into microsoft:main Nov 17, 2023
6 checks passed
@AArnott AArnott deleted the analyzerFixes branch November 17, 2023 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants