@@ -49,16 +49,13 @@ public override void Initialize(AnalysisContext context)
4949 var stringType = context . Compilation . GetSpecialType ( SpecialType . System_String ) ;
5050 var hasAnyStartsWith = false ;
5151 var hasStartsWithCharOverload = false ;
52- foreach ( var startsWith in stringType . GetMembers ( "StartsWith" ) )
52+ foreach ( var startsWithMethod in stringType . GetMembers ( "StartsWith" ) . OfType < IMethodSymbol > ( ) )
5353 {
54- if ( startsWith is IMethodSymbol startsWithMethod )
54+ hasAnyStartsWith = true ;
55+ if ( startsWithMethod . Parameters is [ { Type . SpecialType : SpecialType . System_Char } ] )
5556 {
56- hasAnyStartsWith = true ;
57- if ( startsWithMethod . Parameters is [ { Type . SpecialType : SpecialType . System_Char } ] )
58- {
59- hasStartsWithCharOverload = true ;
60- break ;
61- }
57+ hasStartsWithCharOverload = true ;
58+ break ;
6259 }
6360 }
6461
@@ -68,26 +65,23 @@ public override void Initialize(AnalysisContext context)
6865 }
6966
7067 var indexOfMethodsBuilder = ImmutableArray . CreateBuilder < ( IMethodSymbol IndexOfSymbol , string OverloadPropertyValue ) > ( ) ;
71- foreach ( var indexOf in stringType . GetMembers ( "IndexOf" ) )
68+ foreach ( var indexOfMethod in stringType . GetMembers ( "IndexOf" ) . OfType < IMethodSymbol > ( ) )
7269 {
73- if ( indexOf is IMethodSymbol indexOfMethod )
70+ if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_String } ] )
7471 {
75- if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_String } ] )
76- {
77- indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadString ) ) ;
78- }
79- else if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_Char } ] )
80- {
81- indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadChar ) ) ;
82- }
83- else if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_String } , { Name : "comparisonType" } ] )
84- {
85- indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadString_StringComparison ) ) ;
86- }
87- else if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_Char } , { Name : "comparisonType" } ] )
88- {
89- indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadChar_StringComparison ) ) ;
90- }
72+ indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadString ) ) ;
73+ }
74+ else if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_Char } ] )
75+ {
76+ indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadChar ) ) ;
77+ }
78+ else if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_String } , { Name : "comparisonType" } ] )
79+ {
80+ indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadString_StringComparison ) ) ;
81+ }
82+ else if ( indexOfMethod . Parameters is [ { Type . SpecialType : SpecialType . System_Char } , { Name : "comparisonType" } ] )
83+ {
84+ indexOfMethodsBuilder . Add ( ( indexOfMethod , OverloadChar_StringComparison ) ) ;
9185 }
9286 }
9387
0 commit comments