@@ -75,7 +75,8 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS
7575 return ;
7676 }
7777
78- var fileName = Path . GetFileName ( context . Tree . FilePath ) ;
78+ string suffix ;
79+ var fileName = GetFileNameAndSuffix ( context . Tree . FilePath , out suffix ) ;
7980 string expectedFileName ;
8081 switch ( settings . DocumentationRules . FileNamingConvention )
8182 {
@@ -97,12 +98,29 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS
9798 }
9899
99100 var properties = ImmutableDictionary . Create < string , string > ( )
100- . Add ( ExpectedFileNameKey , expectedFileName ) ;
101+ . Add ( ExpectedFileNameKey , expectedFileName + suffix ) ;
101102
102103 context . ReportDiagnostic ( Diagnostic . Create ( Descriptor , firstTypeDeclaration . Identifier . GetLocation ( ) , properties ) ) ;
103104 }
104105 }
105106
107+ private static string GetFileNameAndSuffix ( string path , out string suffix )
108+ {
109+ string fileName = Path . GetFileName ( path ) ;
110+ int firstDot = fileName . IndexOf ( '.' ) ;
111+ if ( firstDot >= 0 )
112+ {
113+ suffix = fileName . Substring ( firstDot ) ;
114+ fileName = fileName . Substring ( 0 , firstDot ) ;
115+ }
116+ else
117+ {
118+ suffix = string . Empty ;
119+ }
120+
121+ return fileName ;
122+ }
123+
106124 private static TypeDeclarationSyntax GetFirstTypeDeclaration ( SyntaxNode root )
107125 {
108126 return root . DescendantNodes ( descendIntoChildren : node => node . IsKind ( SyntaxKind . CompilationUnit ) || node . IsKind ( SyntaxKind . NamespaceDeclaration ) )
@@ -114,26 +132,26 @@ private static string GetStyleCopFileName(TypeDeclarationSyntax firstTypeDeclara
114132 {
115133 if ( firstTypeDeclaration . TypeParameterList == null )
116134 {
117- return $ "{ firstTypeDeclaration . Identifier . ValueText } .cs ";
135+ return $ "{ firstTypeDeclaration . Identifier . ValueText } ";
118136 }
119137
120138 var typeParameterList = string . Join ( "," , firstTypeDeclaration . TypeParameterList . Parameters . Select ( p => p . Identifier . ValueText ) ) ;
121- return $ "{ firstTypeDeclaration . Identifier . ValueText } {{{typeParameterList}}}.cs ";
139+ return $ "{ firstTypeDeclaration . Identifier . ValueText } {{{typeParameterList}}}";
122140 }
123141
124142 private static string GetSimpleFileName ( TypeDeclarationSyntax firstTypeDeclaration )
125143 {
126- return $ "{ firstTypeDeclaration . Identifier . ValueText } .cs ";
144+ return $ "{ firstTypeDeclaration . Identifier . ValueText } ";
127145 }
128146
129147 private static string GetMetadataFileName ( TypeDeclarationSyntax firstTypeDeclaration )
130148 {
131149 if ( firstTypeDeclaration . TypeParameterList == null )
132150 {
133- return $ "{ firstTypeDeclaration . Identifier . ValueText } .cs ";
151+ return $ "{ firstTypeDeclaration . Identifier . ValueText } ";
134152 }
135153
136- return $ "{ firstTypeDeclaration . Identifier . ValueText } `{ firstTypeDeclaration . Arity } .cs ";
154+ return $ "{ firstTypeDeclaration . Identifier . ValueText } `{ firstTypeDeclaration . Arity } ";
137155 }
138156 }
139157 }
0 commit comments