Let's say I have an interface:
namespace MyCompany.Security
{
public interface IMySecurable
{
string GetContext();
}
}
Which is implemented by a number of classes, e.g.
namespace MyCompany.Repositories
{
using System.Collections.Generic;
using MyCompany.Security;
public class MyRepository : IMySecurable
{
public IEnumerable<string> GetAll()
{
// Repository logic
}
string IMySecurable.GetContext()
{
// Logic here
}
}
}
I'm using PostSharp attribute multicasting to apply my aspect (MySecurityAspect
) to each class in a namespace.
[assembly: MySecurityAspect(AttributeTargetTypes = "MyCompany.Repositories.*", AttributePriority = 1)]
However I'm unable to figure out how to exclude explicit interface method implementations i.e.
string IMySecurable.GetContext()
{
// Logic here
}
I have tried following the documentation here, using this statement:
[assembly: MySecurityAspect(AttributeTargetMembers = "GetContext", AttributeExclude = true, AttributePriority = 2)]
However this doesn't seem to work.
How can I exclude methods using attribute multicasting when they are explicit interface implementations?