Assembly wide multicast attributes. Are they evil?

Posted by HeavyWave on Stack Overflow See other posts from Stack Overflow or by HeavyWave
Published on 2010-03-22T05:58:26Z Indexed on 2010/03/22 6:01 UTC
Read the original article Hit count: 317

Filed under:
|
|

I am working on a project where we have several attributes in AssemblyInfo.cs, that are being multicast to a methods of a particular class.

[assembly: Repeatable(
AspectPriority = 2,
AttributeTargetAssemblies = "MyNamespace",
AttributeTargetTypes = "MyNamespace.MyClass",
AttributeTargetMemberAttributes = MulticastAttributes.Public,
AttributeTargetMembers = "*Impl", Prefix = "Cls")]

What I don't like about this, is that it puts a piece of login into AssemblyInfo (Info, mind you!), which for starters should not contain any logic at all. The worst part of it, is that the actual MyClass.cs does not have the attribute anywhere in the file, and it is completely unclear that methods of this class might have them. From my perspective it greatly hurts readability of the code (not to mention that overuse of PostSharp can make debugging a nightmare). Especially when you have multiple multicast attributes.

What is the best practice here? Is anyone out there is using PostSharp attributes like this?

© Stack Overflow or respective owner

Related posts about postsharp

Related posts about c#