@@ -33,11 +33,6 @@ internal class AttributeAnalyzer : DiagnosticAnalyzer
3333
3434 public override void Initialize ( AnalysisContext context )
3535 {
36- if ( context == null )
37- {
38- throw new ArgumentNullException ( nameof ( context ) ) ;
39- }
40-
4136 context . EnableConcurrentExecution ( ) ;
4237 context . ConfigureGeneratedCodeAnalysis ( GeneratedCodeAnalysisFlags . Analyze | GeneratedCodeAnalysisFlags . ReportDiagnostics ) ;
4338 context . RegisterSyntaxNodeAction ( c => Handle ( c ) , SyntaxKind . Attribute ) ;
@@ -494,7 +489,7 @@ private static bool HasWrongSyntax(PathSegment segment, out Replacement<Span> re
494489 replacement = default ;
495490 return false ;
496491
497- bool HasWrongIntArgumentSyntax ( RouteConstraint constraint , string methodName , out Span result )
492+ static bool HasWrongIntArgumentSyntax ( RouteConstraint constraint , string methodName , out Span result )
498493 {
499494 var text = constraint . Span ;
500495 if ( text . Length > methodName . Length + 2 &&
@@ -519,7 +514,7 @@ bool HasWrongIntArgumentSyntax(RouteConstraint constraint, string methodName, ou
519514
520515 private static bool HasWrongRegexSyntax ( PathSegment segment , out Replacement < Span > replacement )
521516 {
522- if ( segment . Parameter is TemplateParameter parameter )
517+ if ( segment . Parameter is { } parameter )
523518 {
524519 foreach ( var constraint in parameter . Constraints )
525520 {
@@ -648,7 +643,7 @@ private static bool HasInvalidName(PathSegment segment, out Replacement<Span> re
648643
649644 private static bool ShouldKebabCase ( PathSegment segment , [ NotNullWhen ( true ) ] out string ? kebabCase )
650645 {
651- if ( segment . Parameter == null &&
646+ if ( segment is { Parameter : null } &&
652647 IsHumpOrSnakeCased ( segment . Span ) )
653648 {
654649 kebabCase = KebabCase ( segment . Span . ToString ( ) ) ;
@@ -658,7 +653,7 @@ private static bool ShouldKebabCase(PathSegment segment, [NotNullWhen(true)] out
658653 kebabCase = null ;
659654 return false ;
660655
661- bool IsHumpOrSnakeCased ( Span span )
656+ static bool IsHumpOrSnakeCased ( Span span )
662657 {
663658 for ( var i = 0 ; i < span . Length ; i ++ )
664659 {
@@ -707,7 +702,7 @@ private static string KebabCase(string text)
707702 /// </summary>
708703 private static bool HasSyntaxError ( PathSegment segment , [ NotNullWhen ( true ) ] out Location ? location )
709704 {
710- if ( segment . Parameter == null )
705+ if ( segment . Parameter is null )
711706 {
712707 for ( var i = 0 ; i < segment . Span . Length ; i ++ )
713708 {
@@ -732,8 +727,8 @@ private static bool HasSyntaxError(PathSegment segment, [NotNullWhen(true)] out
732727
733728 private static bool IsMultipleOccurringParameter ( PathSegment segment , UrlAttribute urlAttribute , SyntaxNodeAnalysisContext context , [ NotNullWhen ( true ) ] out Location ? location )
734729 {
735- if ( segment . Parameter is TemplateParameter parameter &&
736- urlAttribute . UrlTemplate is UrlTemplate template )
730+ if ( segment . Parameter is { } parameter &&
731+ urlAttribute . UrlTemplate is { } template )
737732 {
738733 if ( ContainsName ( template . Path ) )
739734 {
@@ -743,8 +738,7 @@ private static bool IsMultipleOccurringParameter(PathSegment segment, UrlAttribu
743738
744739 if ( urlAttribute . TryGetParentMember ( out var parentMember ) )
745740 {
746- if ( parentMember is MethodDeclarationSyntax parentMethod &&
747- parentMethod . Parent is ClassDeclarationSyntax classDeclaration &&
741+ if ( parentMember is MethodDeclarationSyntax { Parent : ClassDeclarationSyntax classDeclaration } &&
748742 TryGetOtherTemplate ( classDeclaration . AttributeLists , out var otherTemplate ) &&
749743 ContainsName ( otherTemplate . Path ) )
750744 {
@@ -822,7 +816,7 @@ private static bool ShouldUseExplicitRoute(PathSegment segment, SyntaxNodeAnalys
822816 private static bool ShouldRenameController ( PathSegment segment , UrlAttribute urlAttribute , SyntaxNodeAnalysisContext context , out Replacement < Location > replacement )
823817 {
824818 if ( urlAttribute . UrlTemplate is { } template &&
825- template . Path . TryLast ( x => x . Parameter == null , out var last ) &&
819+ template . Path . TryLast ( x => x . Parameter is null , out var last ) &&
826820 last == segment &&
827821 segment . Span . Length > 0 &&
828822 segment . Span [ 0 ] != '[' &&
@@ -945,7 +939,7 @@ private static bool TryFindParameter(TemplateParameter templateParameter, Method
945939 result = null ;
946940 return false ;
947941
948- bool IsFromRoute ( ParameterSyntax p )
942+ static bool IsFromRoute ( ParameterSyntax p )
949943 {
950944 foreach ( var attributeList in p . AttributeLists )
951945 {
0 commit comments