Skip to content

Commit

Permalink
Bugfix LC0017 InvalidCastException #156
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanMaron committed Feb 25, 2022
1 parent a69da6b commit 3596619
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Design/Rule0017WriteToFlowField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ private void CheckForWriteToFlowField(OperationAnalysisContext context)

if (context.Operation.Kind == OperationKind.InvocationExpression)
{
IInvocationExpression operation = (IInvocationExpression)context.Operation;
if (operation.TargetMethod.Name == "Validate")
try
{
var FieldClass = ((IFieldAccess)((IConversionExpression)operation.Arguments[0].Value).Operand).FieldSymbol.FieldClass;
if (FieldClass == FieldClassKind.FlowField)
if (!HasExplainingComment(context.Operation))
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0017WriteToFlowField, context.Operation.Syntax.GetLocation()));
IInvocationExpression operation = (IInvocationExpression)context.Operation;
if (operation.TargetMethod.Name == "Validate")
{
var FieldClass = ((IFieldAccess)((IConversionExpression)operation.Arguments[0].Value).Operand).FieldSymbol.FieldClass;
if (FieldClass == FieldClassKind.FlowField)
if (!HasExplainingComment(context.Operation))
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0017WriteToFlowField, context.Operation.Syntax.GetLocation()));
}
}
catch (InvalidCastException)
{ }
}
else
{
Expand Down

0 comments on commit 3596619

Please sign in to comment.