2121 /// </summary>
2222 public class SolutionReader
2323 {
24- private static Regex diagnosticPathRegex = new Regex ( @"(?<type>[A-Za-z]+)Rules\\(?<id>S[A-Z][0-9]{4})(?< name>[A-Za-z0-9]+)\.cs$" ) ;
24+ private static Regex diagnosticPathRegex = new Regex ( @"(?<type>[A-Za-z]+)Rules\\(?<name>[A-Za-z0-9]+)\.cs$" ) ;
2525 private INamedTypeSymbol diagnosticAnalyzerTypeSymbol ;
2626 private INamedTypeSymbol noCodeFixAttributeTypeSymbol ;
2727
@@ -123,7 +123,6 @@ public async Task<ImmutableList<StyleCopDiagnostic>> GetDiagnosticsAsync()
123123 continue ;
124124 }
125125
126- string id = match . Groups [ "id" ] . Value ;
127126 string shortName = match . Groups [ "name" ] . Value ;
128127 CodeFixStatus codeFixStatus ;
129128 string noCodeFixReason = null ;
@@ -140,14 +139,18 @@ public async Task<ImmutableList<StyleCopDiagnostic>> GetDiagnosticsAsync()
140139 continue ;
141140 }
142141
143- bool hasImplementation = HasImplementation ( syntaxRoot ) ;
142+ if ( classSymbol . IsAbstract )
143+ {
144+ continue ;
145+ }
144146
145- codeFixStatus = this . HasCodeFix ( id , classSymbol , out noCodeFixReason ) ;
147+ bool hasImplementation = HasImplementation ( syntaxRoot ) ;
146148
147149 IEnumerable < DiagnosticDescriptor > descriptorInfos = this . GetDescriptor ( classSymbol ) ;
148150
149151 foreach ( var descriptorInfo in descriptorInfos )
150152 {
153+ codeFixStatus = this . HasCodeFix ( descriptorInfo . Id , classSymbol , out noCodeFixReason ) ;
151154 string status = this . GetStatus ( classSymbol , syntaxRoot , semanticModel , descriptorInfo ) ;
152155 if ( descriptorInfo . CustomTags . Contains ( WellKnownDiagnosticTags . NotConfigurable ) )
153156 {
@@ -198,15 +201,27 @@ private string GetStatus(INamedTypeSymbol classSymbol, SyntaxNode root, Semantic
198201
199202 foreach ( var member in members )
200203 {
201- VariableDeclaratorSyntax node = root . FindNode ( member . Locations . FirstOrDefault ( ) . SourceSpan ) as VariableDeclaratorSyntax ;
204+ ObjectCreationExpressionSyntax initializer ;
205+ SyntaxNode node = root . FindNode ( member . Locations . FirstOrDefault ( ) . SourceSpan ) ;
202206
203- if ( node == null )
207+ if ( node != null )
208+ {
209+ initializer = ( node as PropertyDeclarationSyntax ) ? . Initializer ? . Value as ObjectCreationExpressionSyntax ;
210+ if ( initializer == null )
211+ {
212+ initializer = ( node as VariableDeclaratorSyntax ) ? . Initializer ? . Value as ObjectCreationExpressionSyntax ;
213+
214+ if ( initializer == null )
215+ {
216+ continue ;
217+ }
218+ }
219+ }
220+ else
204221 {
205222 continue ;
206223 }
207224
208- ObjectCreationExpressionSyntax initializer = node . Initializer . Value as ObjectCreationExpressionSyntax ;
209-
210225 var firstArgument = initializer . ArgumentList . Arguments [ 0 ] ;
211226
212227 string constantValue = ( string ) model . GetConstantValue ( firstArgument . Expression ) . Value ;
0 commit comments