Esempio n. 1
0
        public override ClassDeclarationSyntax EmitSyntax()
        {
            OutputSyntax = SyntaxFactory.ClassDeclaration(Member.Name.ToPascalCase());

            if (Member.Attributes.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithAttributeLists(EmitAttributeLists());
            }

            OutputSyntax = OutputSyntax.WithModifiers(EmitMemberModifiers());

            if (Member.BaseType != null || Member.Interfaces.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithBaseList(EmitBaseList());
            }

            if (Member.IsGenericDefinition && Member.GenericParameters.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithTypeParameterList(EmitTypeParameterList());
            }

            OutputSyntax = OutputSyntax.WithMembers(EmitMembers());

            return(OutputSyntax);
        }
Esempio n. 2
0
        public override MethodDeclarationSyntax EmitSyntax()
        {
            TypeSyntax returnTypeSyntax = (Member.Signature.IsVoid
                ? SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.VoidKeyword))
                : Member.Signature.ReturnValue.Type.GetTypeNameSyntax());

            OutputSyntax =
                SyntaxFactory.MethodDeclaration(
                    returnTypeSyntax,
                    SyntaxFactory.Identifier(Member.Name)
                    );

            OutputSyntax = OutputSyntax.WithModifiers(EmitMemberModifiers());

            if (Member.Signature.Parameters.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithParameterList(MethodSignatureSyntaxEmitter.EmitParameterListSyntax(Member.Signature));
            }

            if (Member.Attributes.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithAttributeLists(EmitAttributeLists());
            }

            OutputSyntax = OutputSyntax.WithBody(Member.Body.ToSyntax());

            return(OutputSyntax);
        }
Esempio n. 3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public override EnumDeclarationSyntax EmitSyntax()
        {
            OutputSyntax = SyntaxFactory.EnumDeclaration(Member.Name);

            if (Member.Attributes.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithAttributeLists(EmitAttributeLists());
            }

            OutputSyntax = OutputSyntax.WithModifiers(EmitMemberModifiers());
            OutputSyntax = OutputSyntax.WithMembers(EmitEnumMembers());

            return(OutputSyntax);
        }
Esempio n. 4
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public override ConstructorDeclarationSyntax EmitSyntax()
        {
            OutputSyntax = SyntaxFactory.ConstructorDeclaration(SyntaxFactory.Identifier(Member.DeclaringType.Name.ToPascalCase()));

            if (Member.Modifier != MemberModifier.Static)
            {
                OutputSyntax = OutputSyntax.WithModifiers(EmitMemberVisibility());

                if (Member.Signature.Parameters.Count > 0)
                {
                    OutputSyntax = OutputSyntax.WithParameterList(MethodSignatureSyntaxEmitter.EmitParameterListSyntax(Member.Signature));
                }
            }
            else
            {
                OutputSyntax = OutputSyntax.WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.StaticKeyword)));
            }

            if (Member.Attributes.Count > 0)
            {
                OutputSyntax = OutputSyntax.WithAttributeLists(EmitAttributeLists());
            }

            if (Member.CallThisConstructor != null)
            {
                OutputSyntax = OutputSyntax.WithInitializer(
                    SyntaxFactory.ConstructorInitializer(
                        SyntaxKind.ThisConstructorInitializer,
                        Member.CallThisConstructor.GetArgumentListSyntax()));
            }
            else if (Member.CallBaseConstructor != null)
            {
                OutputSyntax = OutputSyntax.WithInitializer(
                    SyntaxFactory.ConstructorInitializer(
                        SyntaxKind.BaseConstructorInitializer,
                        Member.CallBaseConstructor.GetArgumentListSyntax()));
            }

            OutputSyntax = OutputSyntax.WithBody(Member.Body.ToSyntax());

            return(OutputSyntax);
        }
Esempio n. 5
0
        public override PropertyDeclarationSyntax EmitSyntax()
        {
            OutputSyntax = SyntaxFactory.PropertyDeclaration(
                Member.PropertyType.GetTypeNameSyntax(),
                SyntaxFactory.Identifier(Member.Name)
                );

            OutputSyntax = OutputSyntax.WithModifiers(EmitMemberModifiers());

            OutputSyntax = OutputSyntax.WithAccessorList(
                SyntaxFactory.AccessorList(
                    SyntaxFactory.List <AccessorDeclarationSyntax>(new[] {
                SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration)
                .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)),
                SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration)
                .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken))
            })
                    )
                );

            return(OutputSyntax);
        }
Esempio n. 6
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public override PropertyDeclarationSyntax EmitSyntax()
        {
            OutputSyntax = PropertyDeclaration(
                Member.PropertyType.GetTypeNameSyntax(),
                Identifier(Member.Name)
                );

            OutputSyntax = OutputSyntax.WithModifiers(EmitMemberModifiers());

            OutputSyntax = OutputSyntax.WithAccessorList(
                AccessorList(
                    SingletonList <AccessorDeclarationSyntax>(
                        AccessorDeclaration(
                            SyntaxKind.GetAccessorDeclaration
                            )
                        .WithSemicolonToken(
                            Token(SyntaxKind.SemicolonToken)
                            )
                        )
                    )
                );

            return(OutputSyntax);
        }