-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Private protected methods are not intercepted #535
Comments
I assume since your unit test is using Since you've got this far, do you want to confirm that |
I can confirm that this passes: var method = proxy
.GetType()
.GetMethod(
nameof(PrivateProtectedThrowException),
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance
);
Assert.IsTrue(
ProxyUtil.IsAccessibleMethod(method)
); |
My guess is that Core/src/Castle.Core/DynamicProxy/Contributors/MembersCollector.cs Lines 225 to 229 in a7454e5
@CrispyDrone could you add |
I can confirm that the unit test passes. However something that might be interesting is that for the proxy, I assume that I might be wrong though, as I am only just dipping my toes into this codebase and I'm quite tired. In any case I hope this helps! |
@CrispyDrone, thanks for running these tests!
I suspect this by itself is unproblematic, ECMA-335 §II.10.33 specifically allows widening of accessibility in overrides. I vaguely remember having seen instances of such widening somewhere else (possibly in reference assemblies, as they only represent the public-facing parts). There is also a special case for narrowing. I haven't thought about this in detail but I thought I'd post a pointer here. At the surface it doesn't seem like a problem. |
@CrispyDrone, I can confirm that @jonorossi's suggestion fixes this issue, see master...stakx:private-protected-methods. Since it was you who did much of the work (describing the problem, and providing repro code 👍), I think it would be great if you could submit a bug fix PR. Please feel free to steal my commits if you find them useful. Otherwise—if I don't hear back from you during the next two weeks or so—I'll go ahead and submit the above commits as a PR so we get this fixed. |
Hi again. Sorry for the late response, I have been preoccupied with some other things. I'm going to try to submit the PR this weekend. If I don't, feel free to continue without me. |
Actually, I'm fine with you submitting your fix as a PR. I would not feel comfortable with just taking your commits; I hope you understand. An acknowledgement in the changelog is more than enough for me at this time 😄 I'm sure I'll be able to make a real code contribution myself in the future! |
Hello,
it seems that private protected methods are not intercepted, even though I would expect them to be:
This fails on the private protected call, but not on the internal, or protected one.
Is this expected behavior? If not, there is an existing issue in NSubstitute regarding this, and I think the root cause might then be with
dynamicproxy
.The text was updated successfully, but these errors were encountered: