Beispiel #1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public override MethodDeclarationSyntax EmitSyntax()
        {
            TypeSyntax returnTypeSyntax = (Member.Signature.IsVoid
                ? PredefinedType(Token(SyntaxKind.VoidKeyword))
                : Member.Signature.ReturnValue.Type.GetTypeNameSyntax());

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

            OutputSyntax = OutputSyntax.WithModifiers(EmitMemberModifiers());

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

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

            return(OutputSyntax);
        }
Beispiel #2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

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

            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(TokenList(Token(SyntaxKind.StaticKeyword)));
            }

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

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

            return(OutputSyntax);
        }