I’m reading the documentation and see that if you don’t use an interface then Windsor can only intercept virtual methods?
Is this a limitation with Windsor or simply the C# language? I’m looking for an in depth answer.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The C# language is completely irrelevant here. The question is how the interception works at the runtime level.
One technique is inheriting from the class/implementing the interface and using that as a proxy. This can obviously only override virtual methods and interface methods. I suspect Windsor uses this technique. The advantage of this technique is that it doesn’t need anything special. Just create a class at runtime.
Another way is using the profiling API. This allows you to modify the IL of any method, including non virtual ones. This is much more intrusive, and typically only used when testing legacy code.
Yet another way is using IL rewriting at build time. This can add interception points in code you wrote, but not in framework code.