Ejemplo n.º 1
0
        public MemberDeclarationSyntax GetMemberDeclarationSyntax()
        {
            var hasAttributes = AttributeListCollection != null;
            var hasModifiers  = ModifierList != null;
            var declaration   = ConstructorDeclaration(
                Identifier.GetSyntaxToken((!hasAttributes && !hasModifiers) ? DocumentationCommentList : null));

            if (hasAttributes)
            {
                declaration = declaration.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList(DocumentationCommentList));
            }
            if (hasModifiers)
            {
                declaration = declaration.WithModifiers(
                    ModifierList.GetSyntaxTokenList(hasAttributes ? null : DocumentationCommentList));
            }
            if (ConstructorBaseInitializer != null)
            {
                declaration = declaration.WithInitializer(
                    ConstructorBaseInitializer.GetConstructorInitializerSyntax());
            }
            if (ParameterList != null)
            {
                declaration = declaration.WithParameterList(
                    ParameterList.GetParameterListSyntax());
            }
            return(declaration.WithBody(Block.GetBlockSyntax()));
        }
 private XmlAttributeSyntax GetXmlNameAttributeSyntax()
 => XmlNameAttribute(
     XmlName(
         Identifier.GetSyntaxToken()),
     Token(SyntaxKind.DoubleQuoteToken),
     Value.GetIdentifierNameSyntax(),
     Token(SyntaxKind.DoubleQuoteToken));
Ejemplo n.º 3
0
        protected override BaseTypeDeclarationSyntax GetTypeDeclarationSyntax()
        {
            var hasAttributes = AttributeListCollection != null;
            var hasModifiers  = ModifierList != null;
            var declaration   = EnumDeclaration(
                Identifier.GetSyntaxToken((!hasAttributes && !hasModifiers) ? DocumentationCommentList : null));

            if (hasAttributes)
            {
                declaration = declaration.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList(DocumentationCommentList));
            }
            if (hasModifiers)
            {
                declaration = declaration.WithModifiers(
                    ModifierList.GetSyntaxTokenList(hasAttributes ? null : DocumentationCommentList));
            }
            if (BaseList != null)
            {
                declaration = declaration.WithBaseList(
                    BaseList.GetBaseListSyntax());
            }
            return(declaration.WithMembers(
                       EnumMemberList.GetEnumMembers()));
        }
Ejemplo n.º 4
0
        public MemberDeclarationSyntax GetMemberDeclarationSyntax()
        {
            var hasAttributes = AttributeListCollection != null;
            var hasModifiers  = ModifierList != null;
            var declarator    = VariableDeclarator(
                Identifier.GetSyntaxToken());

            if (Initializer != null)
            {
                declarator = declarator.WithInitializer(
                    EqualsValueClause(
                        Initializer.GetExpressionSyntax()));
            }
            var declaration = FieldDeclaration(
                VariableDeclaration(
                    IdentifierName(
                        Identifier.GetSyntaxToken((!hasAttributes && !hasModifiers) ? DocumentationCommentList : null)))
                .WithVariables(
                    SingletonSeparatedList(declarator)));

            if (hasAttributes)
            {
                declaration = declaration.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList(DocumentationCommentList));
            }
            if (hasModifiers)
            {
                declaration = declaration.WithModifiers(
                    ModifierList.GetSyntaxTokenList(hasAttributes ? null : DocumentationCommentList));
            }
            return(declaration);
        }
Ejemplo n.º 5
0
 public EnumMemberDeclarationSyntax GetEnumMemberDeclaration()
 => EqualsValue == null
     ? EnumMemberDeclaration(Identifier.GetSyntaxToken(DocumentationCommentList))
     : EnumMemberDeclaration(Identifier.GetSyntaxToken(DocumentationCommentList))
 .WithEqualsValue(
     EqualsValueClause(
         LiteralExpression(
             SyntaxKind.NumericLiteralExpression,
             Literal(EqualsValue.Value))));
Ejemplo n.º 6
0
 public SimpleBaseTypeSyntax GetSimpleBaseTypeSyntax()
 => TypeArgumentListId == null
     ? SimpleBaseType(
     ParseTypeName(Identifier.Name.Value))
     : SimpleBaseType(
     GenericName(
         Identifier.GetSyntaxToken())
     .WithTypeArgumentList(
         TypeArgumentList.GetTypeArgumentListSyntax()));
Ejemplo n.º 7
0
        protected override BaseTypeDeclarationSyntax GetTypeDeclarationSyntax()
        {
            var hasAttributes = AttributeListCollection != null;
            var hasModifiers  = ModifierList != null;
            var declaration   = StructDeclaration(
                Identifier.GetSyntaxToken((!hasAttributes && !hasModifiers) ? DocumentationCommentList : null));

            if (hasAttributes)
            {
                declaration = declaration.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList(DocumentationCommentList));
            }
            if (hasModifiers)
            {
                declaration = declaration.WithModifiers(
                    ModifierList.GetSyntaxTokenList(hasAttributes ? null : DocumentationCommentList));
            }
            if (BaseList != null)
            {
                declaration = declaration.WithBaseList(
                    BaseList.GetBaseListSyntax());
            }
            if (ConstraintClauseList != null)
            {
                declaration = declaration.WithConstraintClauses(
                    ConstraintClauseList.GetConstraintClauses());
            }
            if (TypeParameterList != null)
            {
                declaration = declaration.WithTypeParameterList(
                    TypeParameterList.GetTypeParameterListSyntax());
            }
            // Get members
            var memberList = new List <MemberDeclarationSyntax>();

            if (FieldList != null)
            {
                memberList.AddRange(FieldList.GetMemberDeclarationSyntax());
            }
            if (ConstructorList != null)
            {
                memberList.AddRange(ConstructorList.GetMemberDeclarationSyntax());
            }
            if (PropertyList != null)
            {
                memberList.AddRange(PropertyList.GetMemberDeclarationSyntax());
            }
            if (MethodList != null)
            {
                memberList.AddRange(MethodList.GetMemberDeclarationSyntax());
            }
            return(memberList.Count == 1
                ? declaration.WithMembers(
                       SingletonList(memberList.First()))
                : declaration.WithMembers(
                       List(memberList)));
        }
 private XmlAttributeSyntax GetXmlTextAttributeSyntax()
 => XmlTextAttribute(
     XmlName(
         Identifier.GetSyntaxToken()),
     Token(SyntaxKind.DoubleQuoteToken),
     Token(SyntaxKind.DoubleQuoteToken))
 .WithTextTokens(
     TokenList(
         XmlTextLiteral(
             TriviaList(),
             Value.Name.Value,
             Value.Name.Value,
             TriviaList())));
Ejemplo n.º 9
0
        public MemberDeclarationSyntax GetMemberDeclarationSyntax()
        {
            var hasAttributes = AttributeListCollection != null;
            var hasModifiers  = ModifierList != null;
            var declaration   = MethodDeclaration(
                IdentifierName(
                    Type.GetSyntaxToken((!hasAttributes && !hasModifiers) ? DocumentationCommentList : null)),
                Identifier.GetSyntaxToken());

            if (hasAttributes)
            {
                declaration = declaration.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList(DocumentationCommentList));
            }
            if (hasModifiers)
            {
                declaration = declaration.WithModifiers(
                    ModifierList.GetSyntaxTokenList(hasAttributes ? null : DocumentationCommentList));
            }
            if (ParameterList != null)
            {
                declaration = declaration.WithParameterList(
                    ParameterList.GetParameterListSyntax());
            }
            if (TypeParameterList != null)
            {
                declaration = declaration.WithTypeParameterList(
                    TypeParameterList.GetTypeParameterListSyntax());
            }
            return((ArrowClauseExpressionValue != null)
                ? declaration
                   .WithExpressionBody(
                       ArrowExpressionClause(
                           ArrowClauseExpressionValue.GetExpressionSyntax()))
                   .WithSemicolonToken(
                       Token(SyntaxKind.SemicolonToken))
                : (Block != null)
                ? declaration.WithBody(
                       Block.GetBlockSyntax())
                : declaration.WithSemicolonToken(
                       Token(SyntaxKind.SemicolonToken)));
        }
Ejemplo n.º 10
0
        public ParameterSyntax GetParameterSyntax()
        {
            var parameter = Parameter(
                Identifier.GetSyntaxToken())
                            .WithType(
                Type.GetTypeSyntax());

            if (AttributeListCollection != null)
            {
                parameter = parameter.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList());
            }
            if (DefaultValue != null)
            {
                parameter = parameter.WithDefault(
                    EqualsValueClause(
                        DefaultValue.GetExpressionSyntax()));
            }
            return(parameter);
        }
Ejemplo n.º 11
0
        public MemberDeclarationSyntax GetMemberDeclarationSyntax()
        {
            var hasAttributes = AttributeListCollection != null;
            var hasModifiers  = ModifierList != null;
            var declaration   = PropertyDeclaration(
                IdentifierName(
                    Type.GetSyntaxToken((!hasAttributes && !hasModifiers) ? DocumentationCommentList : null)),
                Identifier.GetSyntaxToken());

            if (hasAttributes)
            {
                declaration = declaration.WithAttributeLists(
                    AttributeListCollection.GetAttributeListSyntaxList(DocumentationCommentList));
            }
            if (hasModifiers)
            {
                declaration = declaration.WithModifiers(
                    ModifierList.GetSyntaxTokenList(hasAttributes ? null : DocumentationCommentList));
            }
            return(declaration.WithAccessorList(
                       AccessorList.GetAccessorListSyntax()));
        }
Ejemplo n.º 12
0
 public IEnumerable <XmlNodeSyntax> GetXmlNodeSyntaxList()
 => new XmlNodeSyntax[]
 {
     XmlText().WithTextTokens(GetTextTokens()),
     XmlExampleElement(
         SingletonList <XmlNodeSyntax>(
             XmlText()
             .WithTextTokens(
                 TokenList(
                     XmlTextLiteral(
                         TriviaList(),
                         Text.Value,
                         Text.Value,
                         TriviaList())))))
     .WithStartTag(
         XmlElementStartTag(
             XmlName(
                 Identifier.GetSyntaxToken())))
     .WithEndTag(
         XmlElementEndTag(
             XmlName(
                 Identifier.GetSyntaxToken())))
 };
Ejemplo n.º 13
0
 public TypeParameterSyntax GetTypeParameterSyntax()
 => TypeParameter(Identifier.GetSyntaxToken());
Ejemplo n.º 14
0
 public DestructorDeclarationSyntax GetDestructorDeclarationSyntax()
 => DestructorDeclaration(Identifier.GetSyntaxToken())
 .WithBody(Block.GetBlockSyntax());