コード例 #1
0
        public PropertyDeclarationSyntax CreateProperty()
        {
            PropertyDeclarationSyntax declaration = Property.IsConstant == true?
                                                    SF.PropertyDeclaration
                                                    (
                GetAttributeLists(),
                GetModifierList(),
                GetReturnType(),
                GetExplicitInterfaceSpecifier(),
                GetIdentifier(),
                GetAccessorList(),
                null,
                GetInitializer(),
                SF.Token(SyntaxKind.SemicolonToken)
                                                    ) :
                                                        SF.PropertyDeclaration
                                                        (
                                                            GetAttributeLists(),
                                                            GetModifierList(),
                                                            GetReturnType(),
                                                            GetExplicitInterfaceSpecifier(),
                                                            GetIdentifier(),
                                                            GetAccessorList()
                                                        );

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

                declaration = declaration.WithLeadingTrivia(trivia);
            }

            return(declaration);
        }
コード例 #2
0
        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());
        }