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
Interception through dynamic proxies #383
Interception through dynamic proxies #383
Conversation
@DixonD-git Dude, you're awesome! I'll take a harder look at this later today but I can't imagine not taking it. If you're comfortable with dynamic proxies and Castle Core, do you think you'd be interested in revamping the Typed Factory library? |
@jeremydmiller I wish I know what the Typed Factory library is :) |
@DixonD-git I'd definitely like to see this get in here and I think this is a good start. I think I'd like to see some kind of reusable Before we pull this in for real, I think I want to go ahead and do #388 just to get rid of the potential conflict in Castle.Core version from RhinoMocks. That one's on me. Bookkeeping things for later
For typed factories, see what Windsor does as an example: https://github.com/castleproject/Windsor/blob/master/docs/typed-factory-facility-interface-based.md. I've never wanted this because I just don't think it's that big a deal to just use the container itself, but other folks have wanted it. The existing code is completely broken anyway, so it's almost starting over from scratch. You'd end up building an implementation on the fly that builds up either a configured instance or explicit args and then delegates to the underlying Container. Would you be up for that? |
And the [TestCase] usage doesn't work w/ Fixie from the command line or TD.Net. It accidentally works with the R# runner and maybe the VS runner. That's probably just a matter of configuring the Fixie conventions. |
Did some more work here:
We need to test all this stuff properly, I suspect a bunch of bugs are there:) As for typed factories, yes, it looks interesting for me, I'll try to pick this up once I have a chance, although from the first look I've got impression that typed factories are not something that could be widely used. Anyway it is nice to have, I guess. |
I had concerns about |
You know that .NET 4.5 has So you can capture and rethrow an exception, preseving all its stack trace and Watson information 😄
|
@khellang Thanks, I didn't know that. Anyway, I'm not sure if we benefit from using
i.e. we still need to throw to get a stack trace. |
With the last commit, I made it work with both variants - |
Hey @DixonD-git, do you want me to pull this in now? I lost track of SM for a bit. |
@jeremydmiller I would like you to review it properly, as the stuff is pretty complex. So, I guess, it's better to wait when you find time for it (whenever it is going to happen) than just merge it right away into master (unless I'm mistaken what "to pull in" means) |
@DixonD-git I looked through it, and TBH, I don't have any hard recommendations for changing anything. What I do suggest though, is that we move this into a completely different repo so it can get its own release schedule and not make you have to use the same build tool chain for that matter. I might vote to do the same for the AutoFactory as well. I can help set up the repo's and definitely help with the CI builds. Unfortunately, I'm about to thoroughly screw everything up in the SM codebase by making the conversion to the DNX project system and the CoreCLR stuff. I might even take the AutoFactory code out of the solution for now. |
@jeremydmiller As for me, moving to another repo has cons as well. Mainly, if you have it in the same repo, you can easily branch everything if you need to make changes in several projects at once. But I'm fine with moving to separate repo as well. But is it possible to keep it under https://github.com/structuremap at least? |
@DixonD-git Thanks for doing this work. This is awesome! I've tried it out in my project and it was easy to integrate. My one comment is that DynamicProxyInterceptorPolicy only takes instances of IInterceptionBehavior instead of types. I think it will be more common for people to want StructureMap to resolve the IInterceptionBehavior. I created a pull request on your branch to add support for this. |
After using this code for a few interceptors, I have found that the IMethodInvocation interface should expose more of the DynamicProxy IInvocation properties in order to perform all of the interceptor activities I need to do. I've created a pull request on @DixonD-git branch to add these properties. |
0ced167
to
478e249
Compare
…es instead of just instances.
…zy load for argumetns and argumentmap
478e249
to
fa57e89
Compare
Honestly, let's just get this in right now and let it build. I'll finally take a better look soon, but I'll wait for you to say when you want me to publish the Nuget. Or you could do it yourself if you want by just downloading it from the TeamCity feed |
My attempt to address what I asked in #364. I've added it as a separate project since a dependency on
Castle.Core
is introduced. The key component isDynamicProxyInterceptor
, the rest are merely wrappers overCastle.Core
stuff.Please, let me know in case of any questions. I know that I should have commented all public classes at least, I may do so later. If this PR is accepted, most probably it will be followed up by another PR with some base interceptors for intercepting async methods (I need to think more about it)