我希望能够将属性应用于接口,以便实现该接口的任何类中的每个方法都将应用属性。
我认为它看起来像这样:
[Serializable]
[AttributeUsage(AttributeTargets.All, Inherited = true)]
public sealed class TestAttribute : OnMethodBoundaryAspect
{
...
}
然而,当我将它应用于如下接口时,在实现接口的类中调用该方法时,永远不会访问属性中的 OnEntry/OnExit 代码:
[Test]
public interface ISystemService
{
List<AssemblyInfo> GetAssemblyInfo();
}
如果我在实现类本身中应用该属性,如下所示,它可以正常工作:
[Test]
public class SystemService : ISystemService
{
...
}
我错过了什么/做错了什么?