コード例 #1
0
 private static BlockSyntax GenerateBlock(IMethodSymbol accessor)
 {
     return(SyntaxFactory.Block(
                StatementGenerator.GenerateStatements(
                    CodeGenerationMethodInfo.GetStatements(accessor)
                    )
                ));
 }
コード例 #2
0
ファイル: StatementGenerator.cs プロジェクト: belav/roslyn
 internal static BlockSyntax GenerateBlock(IMethodSymbol method)
 {
     return(SyntaxFactory.Block(
                StatementGenerator.GenerateStatements(
                    CodeGenerationMethodInfo.GetStatements(method)
                    )
                ));
 }
コード例 #3
0
        private static BlockSyntax GenerateBlock(
            IMethodSymbol constructor)
        {
            var statements = CodeGenerationDestructorInfo.GetStatements(constructor) == null
                ? default(SyntaxList <StatementSyntax>)
                : StatementGenerator.GenerateStatements(CodeGenerationDestructorInfo.GetStatements(constructor));

            return(SyntaxFactory.Block(statements));
        }
コード例 #4
0
        private static TDeclarationNode AddStatementsToMemberDeclaration <TDeclarationNode>(TDeclarationNode destinationMember, IEnumerable <SyntaxNode> statements, MemberDeclarationSyntax memberDeclaration) where TDeclarationNode : SyntaxNode
        {
            var body = memberDeclaration.GetBody();

            if (body == null)
            {
                return(destinationMember);
            }

            var statementNodes = body.Statements.ToList();

            statementNodes.AddRange(StatementGenerator.GenerateStatements(statements));

            var finalBody   = body.WithStatements(SyntaxFactory.List <StatementSyntax>(statementNodes));
            var finalMember = memberDeclaration.WithBody(finalBody);

            return(Cast <TDeclarationNode>(finalMember));
        }