private static IEnumerable<TypeDeclaration> GetTypeDeclarations(NamespaceDeclaration namespaceDeclaration)
{
var collector = new TypeCollector();
return namespaceDeclaration.SyntaxNodes
.Select(info =>
{
Func<TypeDeclarationSyntax, TypeDeclarationSyntaxInfo> selector =
x => new TypeDeclarationSyntaxInfo(info.CodeFile, x.SyntaxTree == null ? x.Identifier.ValueText : x.GetName(x.SyntaxTree.GetRoot()), x);
return new { info, selector };
})
.SelectMany(x => collector.GetTypes(x.info.Syntax).Select(x.selector))
.GroupBy(x => x.Name)
.Select(x => new TypeDeclaration { Name = x.Key, SyntaxNodes = x });
}