private static void AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context)
{
var syntaxRoot = context.Tree.GetRoot(context.CancellationToken);
var outerTypeDeclarations =
syntaxRoot.DescendantNodes(DoNotDescendIntoTypeDeclarations).Where(NodeIsTypeDeclaration).ToList();
var innerTypeDeclarations = (from node in outerTypeDeclarations
from innerNode in node.DescendantNodes().Where(NodeIsTypeDeclaration)
select innerNode).Cast<BaseTypeDeclarationSyntax>();
foreach (var identifier in
from typeDeclaration in innerTypeDeclarations
where typeDeclaration.Modifiers.Count(t => t.Kind() == SyntaxKind.InternalKeyword ||
t.Kind() == SyntaxKind.PublicKeyword) > 0
select typeDeclaration.Identifier)
{
context.ReportDiagnostic(Diagnostic.Create(Rule, identifier.GetLocation(), identifier.Text));
}
}