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

Update VSTHRD110 to handle conditional access expressions #867

Merged
merged 1 commit into from Jun 22, 2021

Conversation

bluetarpmedia
Copy link
Contributor

@bluetarpmedia bluetarpmedia commented Jun 16, 2021

VSTHRD110 now detects a ConditionalAccessExpressionSyntax parent of the invocation.

Closes #772

@bluetarpmedia
Copy link
Contributor Author

Linux job had these errors; problem with the agent?

##[error]The job running on agent Hosted Agent ran longer than the maximum time of 60 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134
,##[warning]Agent Hosted Agent did not respond to a cancelation request with 00:05:00.

@AArnott AArnott changed the title Fix for #772 Update VSTHRD110 to handle conditional access expressions Jun 22, 2021
Copy link
Member

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you.

@@ -46,7 +46,7 @@ internal void AnalyzeInvocation(SyntaxNodeAnalysisContext context)

// Only consider invocations that are direct statements. Otherwise, we assume their
// result is awaited, assigned, or otherwise consumed.
if (invocation.Parent?.GetType().Equals(typeof(ExpressionStatementSyntax)) ?? false)
if (invocation.Parent is ExpressionStatementSyntax || invocation.Parent is ConditionalAccessExpressionSyntax)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tip: this can be written even more succinctly as:

if (invocation.Parent is ExpressionStatementSyntax or ConditionalAccessExpressionSyntax)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good to know.

@AArnott AArnott added this to the v17.0 milestone Jun 22, 2021
@AArnott AArnott merged commit ece5aa6 into microsoft:main Jun 22, 2021
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.

VSTHRD110 does not trigger when using null-conditional member access
2 participants