public static SyntaxTree Rewrite(Compilation compilation, SyntaxTree tree) { var result = new TypeInfoRewriter(compilation.GetSemanticModel(tree)).Visit(tree.GetRoot()); compilation = compilation.ReplaceSyntaxTree(tree, result.SyntaxTree); return(new RemoveUsingsRewriter(compilation.GetSemanticModel(result.SyntaxTree)).Visit(result).SyntaxTree); }
public static SyntaxTree[] GetNamespaceTypes(this Compilation compilation, Func <ITypeSymbol, bool> func) { var providerType = compilation.GlobalNamespace.GetAllTypes().Single(func); return(providerType.ContainingNamespace.Locations .Select(x => TypeInfoRewriter.Rewrite(compilation, x.SourceTree !)) .ToArray()); }