I'm making a call equivalent to: x.m(99)
Using DefaultOverloadResolver. At runtime, x's class has methods named m with signatures
I want the ByRef version to be called only if I have explicitly set up a by-ref argument. Thus, I want the 'Object m(Object)' called in this case.
I probably don't need to sketch the flow through OverloadResolver.ResolveOverload that ends up with the second version being called and returning an object array for anyone who can conceivably answer my question, but if I'm mistaken, perhaps someone could
I can see call to OverloadResolver.AddBasicMethodTargets that calls ParameterMapping.CreateByRefReducedCandidate that automatically returns the second method as a candidate even though I'm passing an Int32 and not an Int32/StrongBox<Int32> -- I don't
see a way to avoid this. So I end up with both methods being considered, with the second one appearing to be ignoring the its by-ref-ness. I thought perhaps deriving my own class from DefaultBinder to override CanConvertFrom might work (if
I could figure out the details), but it appears the OverloadResolver.CanConvertFrom doesn't end up calling the binder's CanConvertFrom: it short circuits because forthe candidate produced by CreateByRefReducedCandidate, the type of the argument appears
to be Int32 instead of Int32&, so it matches 99 just fine.
Where do I put some code to cause the first method to be preferred over the second? Or, how do I prevent matches against a by-ref parameter unless I've specified that I'm passing a by-ref argument?