예제 #1
0
        public ConstructorDeclarationSyntax Generate(MethodDescription description)
        {
            var modifiers = description.ModifiersDescriptions
                            .ToTokens(isFieldModifiers: false)
                            .ToArray();

            return(SyntaxFactory
                   .ConstructorDeclaration(description.Name)
                   .AddModifiers(modifiers)
                   .AddParameters(description.ParametersDescription)
                   .WithBody(methodBodyGetter.GetBodyFor(description)));
        }
        public MethodDeclarationSyntax Generate(MethodDescription description)
        {
            var modifiersDescription = description.ModifiersDescriptions;
            var modifiers            = modifiersDescription.ToTokens(isFieldModifiers: false);

            modifiers = AddDefaultModifiers(modifiers, modifiersDescription);

            var returnType = SyntaxFactory.ParseTypeName(description.ReturnType);

            if (description.ReturnType == "void")
            {
                returnType = SyntaxFactory.PredefinedType(
                    SyntaxFactory.Token(SyntaxKind.VoidKeyword));
            }

            return(SyntaxFactory
                   .MethodDeclaration(returnType, description.Name)
                   .AddModifiers(modifiers.ToArray())
                   .AddParameters(description.ParametersDescription)
                   .WithBody(methodBodyGetter.GetBodyFor(description)));
        }