public void TestGetInvocationReal()
        {
            // generated automatically with RoslynQuoter
            var expectedEnvCallObjectMethodExpression = SyntaxFactory
                                                        .InvocationExpression(
                SyntaxFactory.MemberAccessExpression(
                    SyntaxKind.SimpleMemberAccessExpression,
                    SyntaxFactory.IdentifierName("Env"),
                    SyntaxFactory.IdentifierName("CallObjectMethod")))
                                                        .WithArgumentList(SyntaxFactory.ArgumentList(
                                                                              SyntaxFactory.SeparatedList <ArgumentSyntax>(new SyntaxNodeOrToken[] {
                SyntaxFactory.Argument(
                    SyntaxFactory.MemberAccessExpression(
                        SyntaxKind.SimpleMemberAccessExpression,
                        SyntaxFactory.IdentifierName("jObject"),
                        SyntaxFactory.IdentifierName("Ptr"))),
                SyntaxFactory.Token(SyntaxKind.CommaToken),
                SyntaxFactory.Argument(
                    SyntaxFactory.MemberAccessExpression(
                        SyntaxKind.SimpleMemberAccessExpression,
                        SyntaxFactory.IdentifierName("GetClassNameMethod"),
                        SyntaxFactory.IdentifierName("Ptr")))
            })));
            var actualEnvCallObjectMethodExpression =
                MethodBodyGetter.GetInvocationFor(
                    "Env", "CallObjectMethod",
                    MethodBodyGetter.GetMember("jObject", "Ptr"),
                    MethodBodyGetter.GetMember("GetClassNameMethod", "Ptr"));

            Assert.AreEqual(
                expectedEnvCallObjectMethodExpression.ToString(),
                actualEnvCallObjectMethodExpression.ToString());
        }
        public BlockSyntax GetBodyFor(MethodDeclarationSyntax methodDeclaration)
        {
            var body = new List <StatementSyntax>();
            var usingStatementBody = SyntaxFactory.Block();

            var envCallObjectMethodExpression = MethodBodyGetter.GetInvocationFor(
                "Env", "CallObjectMethod",
                MethodBodyGetter.GetMember("jObject", "Ptr"),
                MethodBodyGetter.GetMember("GetClassNameMethod", "Ptr"));

            var declaration = SyntaxFactory
                              .VariableDeclaration(SyntaxFactory.IdentifierName("var"))
                              .WithVariables(SyntaxFactory.SingletonSeparatedList(SyntaxFactory
                                                                                  .VariableDeclarator(SyntaxFactory.Identifier("a"))
                                                                                  .WithInitializer(SyntaxFactory.EqualsValueClause(envCallObjectMethodExpression))));

            var usingStatement = SyntaxFactory.UsingStatement(
                declaration, null, usingStatementBody)
                                 .NormalizeWhitespace();

            body.Add(usingStatement);
            var res = SyntaxFactory.Block(body);

            return(res);
        }
        public void TestGetInvocationSimple()
        {
            var result = MethodBodyGetter.GetInvocationFor(
                "obj", "DoSmth",
                SyntaxFactory.IdentifierName("localVar"));

            Assert.AreEqual("obj.DoSmth(localVar)", result.ToString());
        }
        public void TestGetInvocationComplex()
        {
            var result = MethodBodyGetter.GetInvocationFor(
                "obj", "DoSmth",
                SyntaxFactory.IdentifierName("localVar"),
                SyntaxFactory.IdentifierName("anotherVar"),
                SyntaxFactory.ObjectCreationExpression(
                    SyntaxFactory.IdentifierName("A"))
                .WithArgumentList(SyntaxFactory.ArgumentList())
                .NormalizeWhitespace());

            Assert.AreEqual("obj.DoSmth(localVar,anotherVar,new A())", result.ToString());
        }
        public void TestGetMethod()
        {
            var result = MethodBodyGetter.GetMember("Object", "Member");

            Assert.AreEqual("Object.Member", result.ToString());
        }