The C# compiler automatically tries appending the suffix Attribute
when you're using an attribute (which is obvious syntactically). It just makes things easier. From the C# 5 spec section 17.2 (Attribute Specification):
By convention, attribute classes are named with a suffix of Attribute
. An attribute-name of the form type-name may either include or omit this suffix. If an attribute class is found both with and without this suffix, an ambiguity is present, and a compile-time error results. If the attribute-name is spelled such that its right-most identifier is a verbatim identifier (§2.4.2), then only an attribute without a suffix is matched, thus enabling such an ambiguity to be resolved.
You should be able to use your [Jeffthroize]
example - it's hard to tell why you can't in your specific situation, without seeing the code and the error message.
For example, this is fine:
using System;
[AttributeUsage(AttributeTargets.All)]
class FooAttribute : Attribute {}
[FooAttribute] // Full name
class Test
{
[Foo] // Abbreviated name
public static void Main() {}
}
If you tried to use [@Foo]
, that would be invalid - but [@FooAttribute]
is valid.
Also note that VB has the same shorthand.