Created
October 25, 2015 19:17
-
-
Save JoshVarty/a5a929deb6cc744cfa0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomSymbolFinder | |
{ | |
public List<INamedTypeSymbol> GetAllSymbols(Compilation compilation) | |
{ | |
var visitor = new FindAllSymbolsVisitor(); | |
visitor.Visit(compilation.GlobalNamespace); | |
return visitor.AllTypeSymbols; | |
} | |
private class FindAllSymbolsVisitor : SymbolVisitor | |
{ | |
public List<INamedTypeSymbol> AllTypeSymbols { get; } = new List<INamedTypeSymbol>(); | |
public override void VisitNamespace(INamespaceSymbol symbol) | |
{ | |
Parallel.ForEach(symbol.GetMembers(), s => s.Accept(this)); | |
} | |
public override void VisitNamedType(INamedTypeSymbol symbol) | |
{ | |
AllTypeSymbols.Add(symbol); | |
foreach (var childSymbol in symbol.GetTypeMembers()) | |
{ | |
base.Visit(childSymbol); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment