Skip to content

Fix IDE0009 false positive on local functions#39228

Merged
allisonchou merged 5 commits intodotnet:masterfrom
allisonchou:FalsePositiveLocalFunc
Oct 15, 2019
Merged

Fix IDE0009 false positive on local functions#39228
allisonchou merged 5 commits intodotnet:masterfrom
allisonchou:FalsePositiveLocalFunc

Conversation

@allisonchou
Copy link
Contributor

Fixes #38043 and adds relevant test.

@allisonchou allisonchou requested a review from a team October 10, 2019 23:12
@sharwell
Copy link
Contributor

This is similar to how DotNetAnalyzers/StyleCopAnalyzers#3023 is resolved, and goes back to a change in the meaning of IsStatic that was implemented Roslyn 3.3. 👍

@jinujoseph jinujoseph added this to the 16.4.P3 milestone Oct 11, 2019
case IInvocationOperation invocationOperation:
return invocationOperation.TargetMethod == null || invocationOperation.TargetMethod.IsStatic;
return invocationOperation.TargetMethod == null || invocationOperation.TargetMethod.IsStatic ||
invocationOperation.TargetMethod is IMethodSymbol { MethodKind: MethodKind.LocalFunction };
Copy link
Contributor

Choose a reason for hiding this comment

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

can we extract a helper that boty of these codepaths should call?

}

private bool IsStaticMemberOrTargetMethod(IOperation operation)
private bool IsMemberOrTargetMethodStaticOrLocalFunction(IOperation operation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like a better name would be IsStaticMemberOrIsLocalFunction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDE0009 false positive on local functions

6 participants