public static bool HasUsingDirective(this CS.CSharpSyntaxTree tree, string fullName) { if (tree == null) { throw new ArgumentNullException(nameof(tree)); } if (string.IsNullOrWhiteSpace(fullName)) { throw new ArgumentException("given namespace cannot be null or empty.", nameof(fullName)); } fullName = fullName.Trim(); return(tree.GetRoot() .DescendantNodes(MatchesNamespaceOrRoot) .OfType <CS.Syntax.UsingDirectiveSyntax>() .Any(u => u.Name.ToString().Equals(fullName, StringComparison.OrdinalIgnoreCase))); }
public static VisualBasicSyntaxNode ConvertCompilationTree(CS.CSharpCompilation compilation, CS.CSharpSyntaxTree tree) { var visualBasicSyntaxVisitor = new NodesVisitor(compilation.GetSemanticModel(tree, true)); return(tree.GetRoot().Accept(visualBasicSyntaxVisitor.TriviaConvertingVisitor)); }