Impossible with common interception strategies.
But most of AOP Framework working at compile time can do it. (example : PostSharp)
I work on an open source NConcern AOP Framework.
This is a simple .NET AOP Framework allowing interception at runtime by swaping methods.
It can do its job for virtual methods, non virtual methods and static method without any factory pattern and inheritance needs.
My recommandation is avoid use AOP to "monkey patch" and static methods must be only "singleton usages shortcut", not a mainstream.
in your case it is easier to use singleton pattern with static methods as shortcup and DI (Dependency Injection) to enable easy proxy pattern.
Example :
interface
public interface IRepository
{
IQueryable<T> Query<T>()
where T : class;
}
the sugar using DI (via a factory)
static public class Repository
{
//You can wrap the interface (proxy) here if you need...
static private readonly IRepository m_Repository = MyDIFactory.Import<IRepository>();
static public IQueryable<T> Query<T>()
where T : class
{
return Repository.m_Repository.Query<T>();
}
}
Usage
Repository.Query<T>().CacheForMinutes(10);
Repository.Query<T>().LogWhenErrorOccurs();