示例#1
0
        public SyntaxTree CreateSyntaxTree()
        {
            // The call to CreateType must come before the call to namespaces.GetUsings.
            // This is because CreateType builds the list of referenced namespaces.
            MemberDeclarationSyntax typeDeclaration = CreateType();

            if (Type.Docs != null)
            {
                DocCommentGeneratorBase <Type> generator = new TypeDocCommentGenerator(Type);
                SyntaxTriviaList trivia = SF.TriviaList(generator.CreateDocComment());

                typeDeclaration = typeDeclaration.WithLeadingTrivia(trivia);
            }

            NamespaceDeclarationSyntax namespaceDeclaration = SF.NamespaceDeclaration(
                Symbols.GetNamespaceSyntax(Type),
                SF.List <ExternAliasDirectiveSyntax>(),
                SF.List <UsingDirectiveSyntax>(),
                SF.List(new[] { typeDeclaration })
                );

            return(SF.SyntaxTree(
                       SF.CompilationUnit(
                           SF.List <ExternAliasDirectiveSyntax>(),
                           Namespaces.GetUsings(),
                           SF.List <AttributeListSyntax>(),
                           SF.List <MemberDeclarationSyntax>(new[] { namespaceDeclaration })
                           ).NormalizeWhitespace(elasticTrivia: true)
                       ));
        }
示例#2
0
        string Render(Docs docs)
        {
            EnumMember member = new EnumMember("member", docs);
            EnumMemberDocCommentGenerator generator = new EnumMemberDocCommentGenerator(member);

            SyntaxTrivia docComment = generator.CreateDocComment();
            SyntaxTree   tree       = SF.SyntaxTree(
                SF.EnumMemberDeclaration("Member")
                .WithLeadingTrivia(generator.CreateDocComment())
                .NormalizeWhitespace(elasticTrivia: true)
                );

            return(tree.ToString());
        }
示例#3
0
        string Render(Docs docs, params Parameter[] parameters)
        {
            Method method = new Method(
                parameters: parameters,
                docs: docs,
                name: "method"
                );

            MethodDocCommentGenerator generator = new MethodDocCommentGenerator(method, Symbols);

            SyntaxTrivia docComment = generator.CreateDocComment();
            SyntaxTree   tree       = SF.SyntaxTree(
                SF.MethodDeclaration(SF.ParseTypeName("void"), "Method")
                .WithLeadingTrivia(generator.CreateDocComment())
                .NormalizeWhitespace(elasticTrivia: true)
                );

            return(tree.ToString());
        }
        string Render(Docs docs)
        {
            Type type = new InterfaceType(
                "myFqn",
                "myModule",
                "myInterfaceName",
                "myInterfaceNamespace",
                docs
                );

            TypeDocCommentGenerator generator = new TypeDocCommentGenerator(type);

            SyntaxTrivia docComment = generator.CreateDocComment();
            SyntaxTree   tree       = SF.SyntaxTree(
                SF.InterfaceDeclaration("MyInterface")
                .WithLeadingTrivia(generator.CreateDocComment())
                .NormalizeWhitespace(elasticTrivia: true)
                );

            return(tree.ToString());
        }
        string Render(Docs docs)
        {
            Property property = new Property(
                "myProp",
                new TypeReference(primitive: PrimitiveType.String),
                false,
                false,
                false,
                docs
                );

            PropertyDocCommentGenerator generator = new PropertyDocCommentGenerator(property);

            SyntaxTrivia docComment = generator.CreateDocComment();
            SyntaxTree   tree       = SF.SyntaxTree(
                SF.PropertyDeclaration(SF.ParseTypeName("string"), "MyProp")
                .WithLeadingTrivia(generator.CreateDocComment())
                .NormalizeWhitespace(elasticTrivia: true)
                );

            return(tree.ToString());
        }