Skip to content

Commit

Permalink
Merge pull request #408 from StefanMaron/development
Browse files Browse the repository at this point in the history
Bound rule0040 to objects of type Record
  • Loading branch information
Arthurvdv authored Dec 7, 2023
2 parents d767e25 + a75d1f8 commit ea02859
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions Design/Rule0040ExplicitlySetRunTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ private void AnalyzeRunTriggerParameters(OperationAnalysisContext ctx)

IInvocationExpression operation = (IInvocationExpression)ctx.Operation;
if (operation.TargetMethod.MethodKind != MethodKind.BuiltInMethod) return;
if (operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() != NavTypeKind.Record) return;
if (!buildInMethodNames.Contains(operation.TargetMethod.Name.ToLowerInvariant())) return;

// We need to verify that the method is called from Record variable to exclude cases like IsolatedStorage.Delete()
if (!ctx.Operation.DescendantsAndSelf().Where(x => x.GetSymbol() != null)
.Where(x => x.Type.GetNavTypeKindSafe() == NavTypeKind.Record)
.Any()) return;

if (operation.Arguments.Where(args => SemanticFacts.IsSameName(args.Parameter.Name, "RunTrigger")).SingleOrDefault() == null)
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0040ExplicitlySetRunTrigger, ctx.Operation.Syntax.GetLocation()));
}
Expand Down

0 comments on commit ea02859

Please sign in to comment.