C# PostSharp-仅附加到WebMethod属性方法

C# PostSharp-仅附加到WebMethod属性方法,c#,attributes,postsharp,C#,Attributes,Postsharp,使用PostSharp,是否只能“附加”到具有WebMethod属性的方法 例: 像个疯子一样在PS社区中搜索。但我还没找到我要找的东西。任何方向正确的评论都是有用的 谢谢 对此没有真正的支持;相反,您应该使用CompoundSpect(将在程序集或类级别使用),并且可以从CompoundSpect.ProvideSpects方法中测试WebMethod自定义属性的存在性 [Trace][WebService] public partial class Service : System.Web.

使用PostSharp,是否只能“附加”到具有WebMethod属性的方法

例:

像个疯子一样在PS社区中搜索。但我还没找到我要找的东西。任何方向正确的评论都是有用的


谢谢

对此没有真正的支持;相反,您应该使用CompoundSpect(将在程序集或类级别使用),并且可以从CompoundSpect.ProvideSpects方法中测试WebMethod自定义属性的存在性

[Trace][WebService]
public partial class Service : System.Web.Services.WebService
{
    // Caught by PS(WebMethod-attribute)
    [WebMethod]
    public void MyMethod()
    {
        return;
    }

    // Not caught by PS
    public void MySecondMethod()
    {
        return;
    }
}