From 3c411ace8d16ad1491c5c28dffca420b181556d1 Mon Sep 17 00:00:00 2001 From: Arthur van de Vondervoort Date: Mon, 8 Jan 2024 13:52:04 +0100 Subject: [PATCH] Verify %1 on filter expression --- Design/Rule0050SetFilterOperatorCharInFilterExpression.cs | 6 ++++++ LinterCopAnalyzers.resx | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Design/Rule0050SetFilterOperatorCharInFilterExpression.cs b/Design/Rule0050SetFilterOperatorCharInFilterExpression.cs index 3b9f4b16..2159c1cb 100644 --- a/Design/Rule0050SetFilterOperatorCharInFilterExpression.cs +++ b/Design/Rule0050SetFilterOperatorCharInFilterExpression.cs @@ -2,6 +2,7 @@ using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics; using Microsoft.Dynamics.Nav.CodeAnalysis.Symbols; using System.Collections.Immutable; +using System.Text.RegularExpressions; namespace BusinessCentral.LinterCop.Design { @@ -39,6 +40,11 @@ private void CheckParameter(IOperation operand, ref IInvocationExpression operat return; string parameterString = operand.Syntax.ToFullString(); + + string pattern = @"%\d+"; // Only when a %1 is used in the filter expression the unsupported operators are threaded as a literal character + Regex regex = new Regex(pattern); + if (!regex.IsMatch(parameterString)) return; + foreach (char unsupportedOperator in unsupportedOperators) { ctx.CancellationToken.ThrowIfCancellationRequested(); diff --git a/LinterCopAnalyzers.resx b/LinterCopAnalyzers.resx index 552fd24d..26e30c28 100644 --- a/LinterCopAnalyzers.resx +++ b/LinterCopAnalyzers.resx @@ -556,12 +556,12 @@ SourceTable property not defined on {0} '{1}'. - Operator '{0}' found in filter expression, currently treated as a literal character. Implement StrSubstNo() to apply '{0}' as operator. + Operator '{0}' found in filter expression, currently treated as a literal character. Implement StrSubstNo() to apply as operator. - Operator '{0}' found in filter expression, currently treated as a literal character. Implement StrSubstNo() to apply '{0}' as operator. + Operator '{0}' found in filter expression, currently treated as a literal character. Implement StrSubstNo() to apply as operator. - Operator '{0}' found in filter expression, currently treated as a literal character. Implement StrSubstNo() to apply '{0}' as operator. + Operator '{0}' found in filter expression, currently treated as a literal character. Implement StrSubstNo() to apply as operator. \ No newline at end of file