diff --git a/src/EditorFeatures/CSharp/UseAutoProperty/UseAutoPropertyAnalyzer.cs b/src/EditorFeatures/CSharp/UseAutoProperty/UseAutoPropertyAnalyzer.cs index 8d3e48427f762ce239b3a69206bddb83d0f7d9a7..f01bc4e844f0f6db3f66cd38ec4982ca76600b25 100644 --- a/src/EditorFeatures/CSharp/UseAutoProperty/UseAutoPropertyAnalyzer.cs +++ b/src/EditorFeatures/CSharp/UseAutoProperty/UseAutoPropertyAnalyzer.cs @@ -46,15 +46,13 @@ protected override bool SupportsPropertyInitializer(Compilation compilation) { AnalyzeMembers(context, namespaceDeclaration.Members, analysisResults); } - - // If we have a class or struct, recurse inwards. - if (member.IsKind(SyntaxKind.ClassDeclaration, out TypeDeclarationSyntax typeDeclaration) || + else if (member.IsKind(SyntaxKind.ClassDeclaration, out TypeDeclarationSyntax typeDeclaration) || member.IsKind(SyntaxKind.StructDeclaration, out typeDeclaration)) { + // If we have a class or struct, recurse inwards. AnalyzeMembers(context, typeDeclaration.Members, analysisResults); } - - if (member is PropertyDeclarationSyntax propertyDeclaration) + else if (member.IsKind(SyntaxKind.PropertyDeclaration, out PropertyDeclarationSyntax propertyDeclaration)) { AnalyzeProperty(context, propertyDeclaration, analysisResults); }