Problem with Ref Parameters
roend83 opened this issue · 8 comments
I am trying to implement this in one of my projects and ran into an issue. I have a WCF service that contains a "ref" parameter. The DisposableServiceChannelProxy class does not properly support this. I debugged through the code and found a way to fix this, but when I tried to submit a PR it said that ChannelAdam.Core has been archived. How do you suggest I go about fixing this?
Hi!
Can you submit a PR to this repository (ChannelAdam.Wcf)?
DisposableServiceChannelProxy.cs is in this repository.
Thanks! 😄
I can, but it will be hacky. The actual change that I had to make was to DisposableRealProxy and DisposableObjectRealProxy. I'll send a PR so you can see what I mean.
Hi @roend83 .
I don't necessarily agree with the pattern of using ref parameters (not that anyone asked!), and I presume you are working on a legacy code base (because now Microsoft says for WCF developers to move to ASP.NET Core or gRPC for all new development)...
I have unarchived ChannelAdam.Core to allow you to submit the PR for review, if you insist you need ref.
Cheers,
Adam
@channeladam totally agree with you about the ref parameters shouldn't be used, but this is a legacy codebase that won't be trivial to change.
I submitted a PR that has updates to this repo only. Let me know if you'd prefer that we put this updates in ChannelAdam.Core and then update the reference here instead. I think that's a better solution long term, but if this project is not going to be modified going forward then it may not matter.
@roend83 Sorry for the delay... I would prefer to put the update in ChannelAdam.Core.
Is the change to DisposableObjectRealProxy.InvokeMethod()
to do:
result = methodInfo.Invoke(onThis, methodCallMessage.Args);
instead of:
result = methodInfo.Invoke(onThis, methodCallMessage.InArgs);
and DisposableRealProxy.Invoke()
to do:
returnMessage = new ReturnMessage(
result, // Operation result
methodCallMessage.Args, // Out arguments
methodCallMessage.ArgCount, // Out arguments count
methodCallMessage.LogicalCallContext, // Call context
methodCallMessage); // Original message
instead of passing in null and 0 for the out arguments and count?
Is there anything other than that (I've only had a quick peek) ?
thanks
That's pretty close. I'll send a PR later today.
@roend83 I believe this works: https://github.com/channeladam/ChannelAdam.Core/pull/2/files
@roend83 please update your NuGet package to ChannelAdam.Core version 1.6.3 - it should now support ref parameters. Please confirm the issue is resolved.