I'm using LinFu's dynamic proxy to add some advice to some classes. The problem is that the proxied objects can only intercept virtual methods and will return the return type's default value for non-virtual met开发者_如何学编程hods.
I can tell whether a class is proxied or not based whether the class or any of it's method has an interception attribute, e.g. [Transaction]
Is it possible to write a ReSharper 5 structural search that would warn if any non-virtual public methods are defined on a class with an interception attribute.
E.g.
Ok
public class InterceptedClass
{
[Transaction]
public virtual void TransactionalMethod()
{
...
}
public virtual void AnotherMethod()
{
...
}
}
Bad
public class InterceptedClass
{
[Transaction]
public virtual void TransactionalMethod()
{
...
}
public void AnotherMethod() // non-virtual method will not be called by proxy
{
...
}
}
Many Thanks.
It is not currently possible with ReSharper 5, AFAIK. We will improve structured patterns to class and in general to design level in one of the next versions. Thanks, and keep this examples coming! We will need many cases :)
精彩评论