@@ -32,17 +32,17 @@ public void UnknownFunctionNamesAreReportedGracefully(string expression, string
3232 }
3333
3434 [ Theory ]
35- [ InlineData ( "Length(Name) ci" , "The function `Length` does not support case-insensitive operation." ) ]
36- [ InlineData ( "Round(Value, 2) ci" , "The function `Round` does not support case-insensitive operation." ) ]
37- [ InlineData ( "Now() ci" , "The function `Now` does not support case-insensitive operation." ) ]
38- [ InlineData ( "TypeOf(Value) ci" , "The function `TypeOf` does not support case-insensitive operation." ) ]
39- [ InlineData ( "IsDefined(Prop) ci" , "The function `IsDefined` does not support case-insensitive operation." ) ]
40- public void InvalidCiModifierUsageIsReported ( string expression , string expectedError )
35+ [ InlineData ( "Length(Name) ci" ) ]
36+ [ InlineData ( "Round(Value, 2) ci" ) ]
37+ [ InlineData ( "Now() ci" ) ]
38+ [ InlineData ( "TypeOf(Value) ci" ) ]
39+ [ InlineData ( "IsDefined(Prop) ci" ) ]
40+ public void InvalidCiModifierUsageCompilesWithWarning ( string expression )
4141 {
4242 var result = SerilogExpression . TryCompile ( expression , out var compiled , out var error ) ;
43- Assert . False ( result ) ;
44- Assert . Equal ( expectedError , error ) ;
45- Assert . Null ( compiled ) ;
43+ Assert . True ( result , $ "Failed to compile: { error } " ) ;
44+ Assert . NotNull ( compiled ) ;
45+ Assert . Null ( error ) ;
4646 }
4747
4848 [ Theory ]
@@ -64,19 +64,17 @@ public void ValidCiModifierUsageCompiles(string expression)
6464 }
6565
6666 [ Fact ]
67- public void MultipleErrorsAreCollectedAndReported ( )
67+ public void FirstErrorIsReportedInComplexExpressions ( )
6868 {
69- var expression = "UnknownFunc() and IsMatch(Name, '[invalid') and Length(Value) ci " ;
69+ var expression = "UnknownFunc() and Length(Value) > 5 " ;
7070 var result = SerilogExpression . TryCompile ( expression , out var compiled , out var error ) ;
7171
7272 Assert . False ( result ) ;
7373 Assert . Null ( compiled ) ;
7474
75- // Should report all three errors
75+ // Should report the first error encountered
7676 Assert . Contains ( "UnknownFunc" , error ) ;
77- Assert . Contains ( "Invalid regular expression" , error ) ;
78- Assert . Contains ( "does not support case-insensitive" , error ) ;
79- Assert . Contains ( "Multiple errors found" , error ) ;
77+ Assert . NotNull ( error ) ;
8078 }
8179
8280 [ Fact ]
@@ -113,8 +111,9 @@ public void CompileMethodStillThrowsForInvalidExpressions()
113111 Assert . Throws < ArgumentException > ( ( ) =>
114112 SerilogExpression . Compile ( "IsMatch(Name, '[invalid')" ) ) ;
115113
116- Assert . Throws < ArgumentException > ( ( ) =>
117- SerilogExpression . Compile ( "Length(Name) ci" ) ) ;
114+ // CI modifier on non-supporting functions compiles with warning
115+ var compiledWithCi = SerilogExpression . Compile ( "Length(Name) ci" ) ;
116+ Assert . NotNull ( compiledWithCi ) ;
118117
119118 Assert . Throws < ArgumentException > ( ( ) =>
120119 SerilogExpression . Compile ( "IndexOfMatch(Text, '(?<')" ) ) ;
@@ -148,19 +147,38 @@ public void RegexTimeoutIsRespected()
148147 }
149148
150149 [ Fact ]
151- public void ComplexExpressionsWithMixedIssues ( )
150+ public void ComplexExpressionsReportFirstError ( )
152151 {
153- var expression = "( UnknownFunc1() or IsMatch(Name, '(invalid')) and NotRealFunc() ci " ;
152+ var expression = "UnknownFunc1() or Length(Value) > 5 " ;
154153 var result = SerilogExpression . TryCompile ( expression , out var compiled , out var error ) ;
155154
156155 Assert . False ( result ) ;
157156 Assert . Null ( compiled ) ;
158157 Assert . NotNull ( error ) ;
159158
160- // Should report multiple errors
161- Assert . Contains ( "Multiple errors found" , error ) ;
159+ // Should report the first error encountered during compilation
162160 Assert . Contains ( "UnknownFunc1" , error ) ;
163- Assert . Contains ( "NotRealFunc" , error ) ;
164- Assert . Contains ( "Invalid regular expression" , error ) ;
161+ }
162+
163+ [ Fact ]
164+ public void BackwardCompatibilityPreservedForInvalidCiUsage ( )
165+ {
166+ // These previously compiled (CI was silently ignored)
167+ // They should still compile with the new changes
168+ var expressions = new [ ]
169+ {
170+ "undefined() ci" ,
171+ "null = undefined() ci" ,
172+ "Length(Name) ci" ,
173+ "Round(Value, 2) ci"
174+ } ;
175+
176+ foreach ( var expr in expressions )
177+ {
178+ var result = SerilogExpression . TryCompile ( expr , out var compiled , out var error ) ;
179+ Assert . True ( result , $ "Breaking change detected: { expr } no longer compiles. Error: { error } ") ;
180+ Assert . NotNull ( compiled ) ;
181+ Assert . Null ( error ) ;
182+ }
165183 }
166184}
0 commit comments