-
Notifications
You must be signed in to change notification settings - Fork 463
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
Cleanup of lightup layer after MS.CA upgrade #6762
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
using System.Linq; | ||
using Analyzer.Utilities; | ||
using Analyzer.Utilities.Extensions; | ||
using Analyzer.Utilities.Lightup; | ||
using Analyzer.Utilities.PooledObjects; | ||
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis; | ||
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.PointsToAnalysis; | ||
|
@@ -1267,9 +1266,8 @@ private bool TryInferConversion( | |
IPatternOperation patternOperation = isPatternOperation.Pattern; | ||
bool direct = true; | ||
|
||
if (INegatedPatternOperationWrapper.IsInstance(patternOperation)) | ||
if (patternOperation is INegatedPatternOperation negatedPattern) | ||
{ | ||
INegatedPatternOperationWrapper negatedPattern = INegatedPatternOperationWrapper.FromOperation(patternOperation); | ||
patternOperation = negatedPattern.Pattern; | ||
direct = false; | ||
} | ||
|
@@ -1582,48 +1580,33 @@ private void PerformPredicateAnalysisCore(IOperation operation, TAnalysisData ta | |
equals: FlowBranchConditionKind == ControlFlowConditionKind.WhenTrue, isReferenceEquality: false, targetAnalysisData: targetAnalysisData); | ||
break; | ||
|
||
default: | ||
// TODO: Remove the below string based checks when we move to Microsoft.CodeAnalysis 3.7 or later. | ||
// TODO: File a tracking bug. | ||
Comment on lines
-1586
to
-1587
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ouch, this would have worked totally fine with lightup. |
||
var kindStr = isPatternOperation.Pattern.Kind.ToString(); | ||
switch (kindStr) | ||
case OperationKind.NegatedPattern: | ||
var negatedPattern = (INegatedPatternOperation)isPatternOperation.Pattern; | ||
if (negatedPattern.Pattern is IConstantPatternOperation negatedConstantPattern) | ||
{ | ||
case "NegatedPattern": | ||
if (isPatternOperation.Pattern.Children.FirstOrDefault() is IPatternOperation negatedPattern) | ||
{ | ||
if (negatedPattern is IConstantPatternOperation negatedConstantPattern) | ||
{ | ||
predicateValueKind = SetValueForEqualsOrNotEqualsComparisonOperator(isPatternOperation.Value, negatedConstantPattern.Value, | ||
equals: FlowBranchConditionKind == ControlFlowConditionKind.WhenFalse, isReferenceEquality: false, targetAnalysisData: targetAnalysisData); | ||
} | ||
|
||
break; | ||
} | ||
else | ||
{ | ||
goto default; | ||
} | ||
predicateValueKind = SetValueForEqualsOrNotEqualsComparisonOperator(isPatternOperation.Value, negatedConstantPattern.Value, | ||
equals: FlowBranchConditionKind == ControlFlowConditionKind.WhenFalse, isReferenceEquality: false, targetAnalysisData: targetAnalysisData); | ||
} | ||
|
||
case "RelationalPattern": | ||
// For the true branch, set the pattern operation value to NotNull. | ||
if (FlowBranchConditionKind == ControlFlowConditionKind.WhenTrue) | ||
{ | ||
predicateValueKind = SetValueForIsNullComparisonOperator(isPatternOperation.Value, equals: false, targetAnalysisData: targetAnalysisData); | ||
} | ||
break; | ||
|
||
break; | ||
case OperationKind.RelationalPattern: | ||
// For the true branch, set the pattern operation value to NotNull. | ||
if (FlowBranchConditionKind == ControlFlowConditionKind.WhenTrue) | ||
{ | ||
predicateValueKind = SetValueForIsNullComparisonOperator(isPatternOperation.Value, equals: false, targetAnalysisData: targetAnalysisData); | ||
} | ||
|
||
case "BinaryPattern": | ||
// These high level patterns should not be present in the lowered CFG: https://github.com/dotnet/roslyn/issues/47068 | ||
predicateValueKind = PredicateValueKind.Unknown; | ||
break; | ||
break; | ||
|
||
default: | ||
Debug.Fail($"Unknown pattern kind '{isPatternOperation.Pattern.Kind}'"); | ||
predicateValueKind = PredicateValueKind.Unknown; | ||
break; | ||
} | ||
case OperationKind.BinaryPattern: | ||
// These high level patterns should not be present in the lowered CFG: https://github.com/dotnet/roslyn/issues/47068 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the root cause for #6755. We will need to figure out performing flow analysis in presence of binary pattern operations. I am working on a separate PR for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be for a bunch of CA1508 too. I'd love to see the correct handling of this will be! |
||
predicateValueKind = PredicateValueKind.Unknown; | ||
break; | ||
|
||
default: | ||
Debug.Fail($"Unknown pattern kind '{isPatternOperation.Pattern.Kind}'"); | ||
predicateValueKind = PredicateValueKind.Unknown; | ||
break; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed files moved to PublicApiAnalyzers project, which is still on MS.CA 1.2.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.2.1? That is Visual Studio 2015? Do we still care about such an old version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sharwell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't any motivating need to update. It works fine and there is no indication that will change.