コード例 #1
0
 public FieldDeclarationSyntax Build() =>
 SF.FieldDeclaration(
     GeneratorHelper.EmptyAttributeList(),
     SF.TokenList(this.modifiers),
     SF.VariableDeclaration(
         fieldType,
         SF.SeparatedList(
             this.variableNames.Select(n => SF.VariableDeclarator(n)))));
コード例 #2
0
 public ConstructorDeclarationSyntax BuildConstructor()
 {
     return(SyntaxFactory.ConstructorDeclaration(
                SyntaxFactory.List <AttributeListSyntax>(),
                SyntaxFactory.TokenList(modifiers),
                identifier,
                GeneratorHelper.ParameterList(parameters),
                default(ConstructorInitializerSyntax),
                blockBody,
                expressionBody));
 }
コード例 #3
0
        public PropertyDeclarationSyntax Build(PropertyType propertyType = PropertyType.ReadonlyGet)
        {
            if (this.propertyType == PropertyType.ReadonlyGet)
            {
                return(SF.PropertyDeclaration(
                           GeneratorHelper.EmptyAttributeList(),
                           SF.TokenList(this.modifiers),
                           this.type,
                           default(ExplicitInterfaceSpecifierSyntax),
                           GeneratorHelper.IdentifierToken(this.identifier),
                           SF.AccessorList(
                               GeneratorHelper.List(
                                   SF.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration)
                                   .WithSemicolonToken(Tokens.Semicolon))),
                           default(ArrowExpressionClauseSyntax),
                           default(EqualsValueClauseSyntax)
                           ));
            }

            throw new NotImplementedException();
        }
コード例 #4
0
        public MethodDeclarationSyntax Build()
        {
            var methodDeclaration = SyntaxFactory.MethodDeclaration(
                SyntaxFactory.List <AttributeListSyntax>(),
                SyntaxFactory.TokenList(modifiers),
                returnType,
                default(ExplicitInterfaceSpecifierSyntax),
                identifier,
                typeParameters,
                GeneratorHelper.ParameterList(parameters),
                typeConstraints != null ?
                SyntaxFactory.List(typeConstraints)
                    : SyntaxFactory.List <TypeParameterConstraintClauseSyntax>(),
                blockBody,
                expressionBody);

            if (expressionBody != null ||
                (expressionBody == null && blockBody == null))
            {
                methodDeclaration = methodDeclaration.WithSemicolonToken(Tokens.Semicolon);
            }

            return(methodDeclaration);
        }