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