@@ -220,23 +220,49 @@ private static bool HasWrongType(ParameterPair pair, out string correctType)
220220
221221 private static bool HasWrongSyntax ( PathSegment segment , out Location location , out string correctSyntax )
222222 {
223- var text = segment . Span . Text ;
224- if ( text . StartsWith ( "{" , StringComparison . Ordinal ) &&
225- ! text . EndsWith ( "}" , StringComparison . Ordinal ) )
223+ if ( segment . Parameter is TemplateParameter parameter )
226224 {
227- location = segment . Span . GetLocation ( ) ;
228- correctSyntax = text + "}" ;
229- return true ;
225+ foreach ( var constraint in parameter . Constraints )
226+ {
227+ var text = constraint . Span . Text ;
228+ if ( text . StartsWith ( "min(" , StringComparison . OrdinalIgnoreCase ) ||
229+ text . StartsWith ( "max(" , StringComparison . OrdinalIgnoreCase ) ||
230+ text . StartsWith ( "minlength(" , StringComparison . OrdinalIgnoreCase ) ||
231+ text . StartsWith ( "maxlength(" , StringComparison . OrdinalIgnoreCase ) ||
232+ text . StartsWith ( "length(" , StringComparison . OrdinalIgnoreCase ) ||
233+ text . StartsWith ( "range(" , StringComparison . OrdinalIgnoreCase ) ||
234+ text . StartsWith ( "regex(" , StringComparison . OrdinalIgnoreCase ) )
235+ {
236+ if ( ! text . EndsWith ( ")" , StringComparison . Ordinal ) )
237+ {
238+ location = constraint . Span . GetLocation ( ) ;
239+ correctSyntax = text + ")" ;
240+ return true ;
241+ }
242+ }
243+ }
230244 }
231-
232- if ( ! text . StartsWith ( "{" , StringComparison . Ordinal ) &&
233- text . EndsWith ( "}" , StringComparison . Ordinal ) )
245+ else
234246 {
235- location = segment . Span . GetLocation ( ) ;
236- correctSyntax = "{" + text ;
237- return true ;
247+ var text = segment . Span . Text ;
248+ if ( text . StartsWith ( "{" , StringComparison . Ordinal ) &&
249+ ! text . EndsWith ( "}" , StringComparison . Ordinal ) )
250+ {
251+ location = segment . Span . GetLocation ( ) ;
252+ correctSyntax = text + "}" ;
253+ return true ;
254+ }
255+
256+ if ( ! text . StartsWith ( "{" , StringComparison . Ordinal ) &&
257+ text . EndsWith ( "}" , StringComparison . Ordinal ) )
258+ {
259+ location = segment . Span . GetLocation ( ) ;
260+ correctSyntax = "{" + text ;
261+ return true ;
262+ }
238263 }
239264
265+
240266 location = null ;
241267 correctSyntax = null ;
242268 return false ;
0 commit comments