@@ -241,6 +241,15 @@ private static bool HasWrongSyntax(PathSegment segment, out Location location, o
241241 }
242242 }
243243
244+ if ( HasWrongIntArgumentSyntax ( constraint , "min" , out location ) ||
245+ HasWrongIntArgumentSyntax ( constraint , "max" , out location ) ||
246+ HasWrongIntArgumentSyntax ( constraint , "minlength" , out location ) ||
247+ HasWrongIntArgumentSyntax ( constraint , "maxlength" , out location ) )
248+ {
249+ correctSyntax = null ;
250+ return true ;
251+ }
252+
244253 if ( ! text . Equals ( "?" , StringComparison . OrdinalIgnoreCase ) &&
245254 ! text . Equals ( "int" , StringComparison . OrdinalIgnoreCase ) &&
246255 ! text . Equals ( "bool" , StringComparison . OrdinalIgnoreCase ) &&
@@ -286,10 +295,31 @@ private static bool HasWrongSyntax(PathSegment segment, out Location location, o
286295 }
287296 }
288297
289-
290298 location = null ;
291299 correctSyntax = null ;
292300 return false ;
301+
302+ bool HasWrongIntArgumentSyntax ( RouteConstraint constraint , string methodName , out Location result )
303+ {
304+ var text = constraint . Span . Text ;
305+ if ( text . Length > methodName . Length + 2 &&
306+ text . StartsWith ( methodName , StringComparison . OrdinalIgnoreCase ) &&
307+ text [ methodName . Length ] == '(' &&
308+ text [ text . Length - 1 ] == ')' )
309+ {
310+ for ( var i = methodName . Length + 1 ; i < text . Length - 2 ; i ++ )
311+ {
312+ if ( ! char . IsDigit ( text [ i ] ) )
313+ {
314+ result = constraint . Span . GetLocation ( i ) ;
315+ return true ;
316+ }
317+ }
318+ }
319+
320+ result = null ;
321+ return false ;
322+ }
293323 }
294324 }
295325}
0 commit comments