Does Csla.Reflection.MethodCaller.CallMethod support ref params?

Does Csla.Reflection.MethodCaller.CallMethod support ref params?

Old forum URL: forums.lhotka.net/forums/t/6782.aspx


mamboer posted on Monday, April 13, 2009

Hello,

It seems that it doesn't...

Here is my test fixture,note that the Can_call_method_having_ref_param() method throw an ArrayTypeMismatchException.

        [TestFixture]
    public class MethodCallerTests
    {
        [Test]
        public void Can_call_method_having_ref_param() {
            //arrange & act
            var item = new TestClass1 { Name="Levin"};
            string xx="";
            MethodCaller.CallMethod(item, "DoSomething",xx);

            //assert
            Assert.AreSame(xx, item.Name);

        }
        [Test]
        public void Can_call_method_having_normal_param() {
            //arrange & act
            var item = new TestClass1 { Name = "Levin" };
            string xx = "";
            MethodCaller.CallMethod(item, "DoSomething1", xx);

            //assert
            Assert.AreEqual("",xx);
        }

        public class TestClass1 {
            public string Name { get; set; }
            public void DoSomething(ref string xx) {
                xx = Name;
            }
            public void DoSomething1(string xx) {
                xx = Name;
            }
        }
    }

RockfordLhotka replied on Monday, April 13, 2009

I don't recall any implementation or design around ref params, no.

Please remember, my goal with any use of reflection or dynamic method invocation is absolutely not to be comprehensive. The design and implementation provides the least features necessary to meet the needs of CSLA .NET itself.

If you want a real dynamic invocation library, look at VB, or the Microsoft DLR, or C# 4.0 when it comes out. I surely don't have time to create/maintain a complete dynamic invocation library :)

RockfordLhotka replied on Monday, April 13, 2009

I should say this too – if you would like to enhance the functionality of Csla.Reflection to include features you want, but that aren’t necessarily required by CSLA .NET, please let me know.

 

I am not against having the functionality be broader – I just don’t personally have time to create or maintain that extended functionality. But if you have time to create and maintain that functionality we can talk about adding you to the dev team.

 

Rocky

 

 

From: RockfordLhotka [mailto:cslanet@lhotka.net]
Sent: Monday, April 13, 2009 9:00 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Does Csla.Reflection.MethodCaller.CallMethod support ref params?

 

I don't recall any implementation or design around ref params, no.

Please remember, my goal with any use of reflection or dynamic method invocation is absolutely not to be comprehensive. The design and implementation provides the least features necessary to meet the needs of CSLA .NET itself.

If you want a real dynamic invocation library, look at VB, or the Microsoft DLR, or C# 4.0 when it comes out. I surely don't have time to create/maintain a complete dynamic invocation library :)



mamboer replied on Monday, April 13, 2009

Wow,I just had a bathe and came back:)
It will absolutely be my honor to join in the Csla.NET dev team and do some contributions.However,my .NET skill may be not good enough(I began to learn c# two years ago)...,which you may care.

Yes,i made this post because i did need that feature,i currently added a overload of CallMethod method to support ref params. I can send you that tiny patch along with my unit tests.



RockfordLhotka replied on Monday, April 13, 2009

Thank you for being willing to contribute.

 

Please email me directly, as I need you to sign a contributor agreement and then we can move forward.

 

Rocky

 

 

From: mamboer [mailto:cslanet@lhotka.net]
Sent: Monday, April 13, 2009 11:25 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: Does Csla.Reflection.MethodCaller.CallMethod support ref params?

 

Wow,I just had a bathe and came back:)
It will absolutely be my honor to join in the Csla.NET dev team and do some contributions.However,my .NET skill may be not good enough(I began to learn c# two years ago)...,which you may care.

Yes,i made this post because i did need that feature,i currently added a overload of CallMethod method to support ref params. I can send you that tiny patch along with my unit tests.





mamboer replied on Monday, April 13, 2009

Ok,i will do that tomorrow morning.It's midnight in China and i'm sleepy.
Have a good day!

Copyright (c) Marimer LLC