waoywssy / linfu

Automatically exported from code.google.com/p/linfu
0 stars 0 forks source link

Argument for generic ref parameter nulled out by proxy implementation #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an interface with a method that takes a generic ref parameter, 
   e.g.
   void SaveOrUpdate<T>(ref T data);
2. Create a proxy for the interface using an implementation of 
   IInvokeWrapper
3. Call SaveOrUpdate on the proxy with valid data.
4. The constructor for InvocationInfo is called with a null item in the   
   'arguments' array and hence IInvokeWrapper.DoInvoke implementation 
   fails.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
Rev 419 on Windows Server 2003.

Please provide any additional information below.

Original issue reported on code.google.com by sudip...@yahoo.com on 6 Aug 2009 at 2:51

GoogleCodeExporter commented 9 years ago

Original comment by Philip.L...@gmail.com on 7 Aug 2009 at 11:24

GoogleCodeExporter commented 9 years ago
Unfortunately, there isn't any way for LinFu.Proxy to handle ref T arguments 
since it
has to know whether or not type 'T' is going to be a reference type or a value 
type
before it can emit the necessary IL instructions that will let you pass your ref
argument down to the interceptor. 

A simple workaround for this would be just to stick with a SaveOrUpdate(T 
target)
method and let type T be either a parameter object or a POCO reference type and 
let
the reference type pass the data by reference for you, if necessary. It's an 
ugly
hack, but it should work.

Original comment by Philip.L...@gmail.com on 9 Aug 2009 at 11:09