Skip to content

VSTHRD003 analyzer false positive fixes#1258

Merged
AArnott merged 3 commits intomicrosoft:mainfrom
AArnott:analyzerFixes
Nov 17, 2023
Merged

VSTHRD003 analyzer false positive fixes#1258
AArnott merged 3 commits intomicrosoft:mainfrom
AArnott:analyzerFixes

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.
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.

2 participants