Beispiel #1
0
        public override Microsoft.CodeAnalysis.SyntaxNode VisitImportsStatement(ImportsStatementSyntax node)
        {
            var newImportsStatement = SyntaxFactory.ImportsStatement();

            newImportsStatement = newImportsStatement.AddImportsClauses(SyntaxFactory.SimpleImportsClause(SyntaxFactory.ParseName(importsName)));

            CompilationUnitSyntax cu = (CompilationUnitSyntax)node.Parent;

            cu = cu.AddImports(newImportsStatement);

            ImportsStatementSyntax newNode = null;

            if (_targetPatternRegEx.Match(node.ImportsClauses.ToString()).Success)
            {
                var existingImports = node.Parent.DescendantNodes().OfType <ImportsStatementSyntax>();

                //newNode = node.AddImportsClauses(new)
                //RecordMatchAndContext(node, BlockType.None);
            }

            return(newNode);
        }
Beispiel #2
0
 public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
 => base.VisitCompilationUnit(node.AddImports(
                                  ImportsStatement(SingletonSeparatedList <ImportsClauseSyntax>(SimpleImportsClause(IdentifierName(typeof(LazyInitializer).Namespace)))),
                                  ImportsStatement(SingletonSeparatedList <ImportsClauseSyntax>(SimpleImportsClause(IdentifierName(typeof(IMocked).Namespace))))));