Simple question, how do you force the C# compiler to throw a compilation error.
Update: Perhaps it's better to use an Assert.Fail()
instead?
I have a custom-attribute that should only be applied to ONE member of a class. Inside of my other class' static method it looks for that one member and I want it to fail (not throw an exception) if more than one member had the attribute applied to it.
public class Foo
{
[MyCustomAttribute]
public String FooString { get; set; }
[MyCustomAttribute]
public String OtherFooString { get; set; }
}
public class Bar<T>
where T : class, new()
{
static Bar()
{
//If more than one member of type Foo has MyCustomAttribute
//applied to it compile error or Assert.Fail()?
}
}