@@ -10,7 +10,7 @@ public abstract class BaseFileSystemNodeAnalyzer : BaseFileSystemAnalyzer
1010 protected override void AnalyzeCompilation ( CompilationStartAnalysisContext compilationStartContext ,
1111 FileSystemContext fileSystemContext )
1212 {
13- if ( typeof ( Path ) . Namespace != GetFileSystemType ( ) . Namespace )
13+ if ( IsNotUsedSystemIo ( ) )
1414 {
1515 return ;
1616 }
@@ -19,7 +19,7 @@ protected override void AnalyzeCompilation(CompilationStartAnalysisContext compi
1919 {
2020 var invocation = ( InvocationExpressionSyntax ) syntaxContext . Node ;
2121
22- if ( invocation . Expression . NormalizeWhitespace ( ) . ToFullString ( ) . StartsWith ( GetFileSystemType ( ) . Name + "." ) )
22+ if ( IsStaticInvocationStartWith ( invocation ) )
2323 {
2424 Analyze ( syntaxContext , invocation ) ;
2525 }
@@ -28,11 +28,11 @@ protected override void AnalyzeCompilation(CompilationStartAnalysisContext compi
2828
2929 compilationStartContext . RegisterSyntaxNodeAction ( syntaxContext =>
3030 {
31- var invocation = ( ObjectCreationExpressionSyntax ) syntaxContext . Node ;
31+ var creationExpressionSyntax = ( ObjectCreationExpressionSyntax ) syntaxContext . Node ;
3232
33- if ( invocation . Type . NormalizeWhitespace ( ) . ToFullString ( ) == GetFileSystemType ( ) . Name )
33+ if ( IsTypesEquals ( creationExpressionSyntax . Type ) )
3434 {
35- Analyze ( syntaxContext , invocation ) ;
35+ Analyze ( syntaxContext , creationExpressionSyntax ) ;
3636 }
3737 } ,
3838 SyntaxKind . ObjectCreationExpression ) ;
@@ -41,5 +41,13 @@ protected override void AnalyzeCompilation(CompilationStartAnalysisContext compi
4141 protected abstract void Analyze ( SyntaxNodeAnalysisContext context , ExpressionSyntax invocation ) ;
4242
4343 protected abstract Type GetFileSystemType ( ) ;
44+
45+ private bool IsNotUsedSystemIo ( ) => typeof ( Path ) . Namespace != GetFileSystemType ( ) . Namespace ;
46+
47+ private bool IsTypesEquals ( TypeSyntax type ) => type . NormalizeWhitespace ( ) . ToFullString ( ) == GetFileSystemType ( ) . Name ;
48+
49+ private bool IsStaticInvocationStartWith ( InvocationExpressionSyntax invocation ) => invocation . Expression . NormalizeWhitespace ( )
50+ . ToFullString ( )
51+ . StartsWith ( GetFileSystemType ( ) . Name + "." ) ;
4452 }
4553}
0 commit comments