@@ -36,38 +36,38 @@ context.ContainingSymbol is IMethodSymbol method &&
3636 {
3737 using ( var pairs = GetPairs ( template , method ) )
3838 {
39- if ( pairs . TrySingle ( x => x . Template == null , out var withMethodParameter ) &&
40- methodDeclaration . TryFindParameter ( withMethodParameter . Method . Name , out var parameterSyntax ) &&
41- pairs . TrySingle ( x => x . Method == null , out var withTemplateParameter ) &&
42- withTemplateParameter . Template is TemplateParameter templateParameter )
39+ if ( pairs . TrySingle ( x => x . FromTemplate == null , out var withMethodParameter ) &&
40+ methodDeclaration . TryFindParameter ( withMethodParameter . FromMethodSymbol . Name , out var parameterSyntax ) &&
41+ pairs . TrySingle ( x => x . FromMethodSymbol == null , out var withTemplateParameter ) &&
42+ withTemplateParameter . FromTemplate is TemplateParameter templateParameter )
4343 {
4444 context . ReportDiagnostic (
4545 Diagnostic . Create (
4646 ASP001ParameterName . Descriptor ,
4747 parameterSyntax . Identifier . GetLocation ( ) ,
4848 ImmutableDictionary < string , string > . Empty . Add (
4949 nameof ( NameSyntax ) ,
50- templateParameter . Name . Text ) ) ) ;
50+ templateParameter . Name . ToString ( ) ) ) ) ;
5151
5252 context . ReportDiagnostic (
5353 Diagnostic . Create (
5454 ASP002MissingParameter . Descriptor ,
5555 templateParameter . Name . GetLocation ( ) ,
5656 ImmutableDictionary < string , string > . Empty . Add (
5757 nameof ( Text ) ,
58- withMethodParameter . Method . Name ) ) ) ;
58+ withMethodParameter . FromMethodSymbol . Name ) ) ) ;
5959 }
60- else if ( pairs . Count ( x => x . Template == null ) > 1 &&
61- pairs . Count ( x => x . Method == null ) > 1 )
60+ else if ( pairs . Count ( x => x . FromTemplate == null ) > 1 &&
61+ pairs . Count ( x => x . FromMethodSymbol == null ) > 1 )
6262 {
6363 context . ReportDiagnostic (
6464 Diagnostic . Create (
6565 ASP001ParameterName . Descriptor ,
6666 methodDeclaration . ParameterList . GetLocation ( ) ) ) ;
6767 }
6868
69- if ( pairs . TryFirst ( x => x . Method == null , out _ ) &&
70- ! pairs . TryFirst ( x => x . Template == null , out _ ) )
69+ if ( pairs . TryFirst ( x => x . FromMethodSymbol == null , out _ ) &&
70+ ! pairs . TryFirst ( x => x . FromTemplate == null , out _ ) )
7171 {
7272 context . ReportDiagnostic (
7373 Diagnostic . Create (
@@ -78,7 +78,7 @@ context.ContainingSymbol is IMethodSymbol method &&
7878 foreach ( var pair in pairs )
7979 {
8080 if ( HasWrongType ( pair , out var typeName ) &&
81- methodDeclaration . TryFindParameter ( pair . Method ? . Name , out parameterSyntax ) )
81+ methodDeclaration . TryFindParameter ( pair . FromMethodSymbol ? . Name , out parameterSyntax ) )
8282 {
8383 context . ReportDiagnostic (
8484 Diagnostic . Create (
@@ -164,7 +164,7 @@ private static PooledList<ParameterPair> GetPairs(UrlTemplate template, IMethodS
164164 {
165165 if ( IsFromRoute ( parameter ) )
166166 {
167- list . Add ( template . Path . TrySingle ( x => x . Parameter ? . Name . Text == parameter . Name , out var templateParameter )
167+ list . Add ( template . Path . TrySingle ( x => x . Parameter ? . Name . Equals ( parameter . Name , StringComparison . Ordinal ) == true , out var templateParameter )
168168 ? new ParameterPair ( templateParameter . Parameter , parameter )
169169 : new ParameterPair ( null , parameter ) ) ;
170170 }
@@ -173,7 +173,7 @@ private static PooledList<ParameterPair> GetPairs(UrlTemplate template, IMethodS
173173 foreach ( var component in template . Path )
174174 {
175175 if ( component . Parameter is TemplateParameter templateParameter &&
176- list . All ( x => x . Template != templateParameter ) )
176+ list . All ( x => x . FromTemplate != templateParameter ) )
177177 {
178178 list . Add ( new ParameterPair ( templateParameter , null ) ) ;
179179 }
@@ -184,13 +184,13 @@ private static PooledList<ParameterPair> GetPairs(UrlTemplate template, IMethodS
184184
185185 private static bool HasWrongType ( ParameterPair pair , out string correctType )
186186 {
187- if ( pair . Template ? . Constraints is ImmutableArray < RouteConstraint > constraints &&
188- pair . Method is IParameterSymbol parameter )
187+ if ( pair . FromTemplate ? . Constraints is ImmutableArray < RouteConstraint > constraints &&
188+ pair . FromMethodSymbol is IParameterSymbol parameter )
189189 {
190190 foreach ( var constraint in constraints )
191191 {
192192 // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2#route-constraint-reference
193- if ( TryGetType ( constraint . Span . Text , out var type ) )
193+ if ( TryGetType ( constraint . Span , out var type ) )
194194 {
195195 correctType = parameter . Type == type ? null : type . Alias ?? type . FullName ;
196196 return correctType != null ;
@@ -201,7 +201,7 @@ private static bool HasWrongType(ParameterPair pair, out string correctType)
201201 correctType = null ;
202202 return false ;
203203
204- bool TryGetType ( string constraint , out QualifiedType type )
204+ bool TryGetType ( StringLiteralSpan constraint , out QualifiedType type )
205205 {
206206 if ( constraint . Equals ( "bool" , StringComparison . Ordinal ) )
207207 {
@@ -275,7 +275,7 @@ private static bool HasWrongSyntax(PathSegment segment, out Location location, o
275275 {
276276 foreach ( var constraint in parameter . Constraints )
277277 {
278- var text = constraint . Span . Text ;
278+ var text = constraint . Span ;
279279 if ( text . StartsWith ( "min(" , StringComparison . OrdinalIgnoreCase ) ||
280280 text . StartsWith ( "max(" , StringComparison . OrdinalIgnoreCase ) ||
281281 text . StartsWith ( "minlength(" , StringComparison . OrdinalIgnoreCase ) ||
@@ -328,7 +328,7 @@ private static bool HasWrongSyntax(PathSegment segment, out Location location, o
328328 }
329329 else
330330 {
331- var text = segment . Span . Text ;
331+ var text = segment . Span ;
332332 if ( text . StartsWith ( "{" , StringComparison . Ordinal ) &&
333333 ! text . EndsWith ( "}" , StringComparison . Ordinal ) )
334334 {
@@ -352,7 +352,7 @@ private static bool HasWrongSyntax(PathSegment segment, out Location location, o
352352
353353 bool HasWrongIntArgumentSyntax ( RouteConstraint constraint , string methodName , out Location result )
354354 {
355- var text = constraint . Span . Text ;
355+ var text = constraint . Span ;
356356 if ( text . Length > methodName . Length + 2 &&
357357 text . StartsWith ( methodName , StringComparison . OrdinalIgnoreCase ) &&
358358 text [ methodName . Length ] == '(' &&
@@ -379,7 +379,7 @@ private static bool HasWrongRegexSyntax(PathSegment segment, out Location locati
379379 {
380380 foreach ( var constraint in parameter . Constraints )
381381 {
382- var text = constraint . Span . Text ;
382+ var text = constraint . Span ;
383383 if ( text . StartsWith ( "regex(" , StringComparison . OrdinalIgnoreCase ) )
384384 {
385385 for ( var i = 6 ; i < text . Length - 1 ; i ++ )
0 commit comments