I have an attribute. Let me call him SomeAttribute . Ideally, it will be defined as follows:
public class SomeAttribute : Attribute { public MyType[] MyObjects { get; set; } public SomeAttribute(params MyType[] parameters) { MyObject = parameters } }
However, due to attribute restrictions, it is defined as follows:
public class SomeAttribute : Attribute { public MyType[] MyObjects { get; set; } public SomeAttribute(params string[] parameters) { MyObject = parameters.DoConvert();
However, if the strings are invalid, I thought I should throw an exception. But I thought that "the attributes are special, I think there should be something else in the exceptions." Then I found the following: http://lostechies.com/jimmybogard/2008/11/23/beware-exceptions-in-attribute-constructors/ . Essentially, it says that βthrowing exceptions in attribute constructors is not a good idea.β
So what should I do here? Should I make an exception? Should I add a bool that returns true if the attribute is invalid?
source share