컴파일러 오류 CS1614

'name'은 'name'과 'nameAttribute' 사이에서 모호합니다. '@name' 또는 'nameAttribute'를 사용합니다.

컴파일러에 모호한 특성 사양 문제가 발생했습니다.

편의상 C# 컴파일러에서 ExampleAttribute를 단순히 [Example]로 지정할 수 있습니다. 그러나 이름이 Example인 특성 클래스가 ExampleAttribute와 함께 존재하면 모호성이 발생합니다. 컴파일러가 [Example]의 참조 대상이 Example 특성인지 ExampleAttribute 특성인지 구분할 수 없기 때문입니다. 모호성을 해소하기 위해 Example 특성에는 [@Example]을, ExampleAttribute에는 [ExampleAttribute]를 사용하세요.

다음 샘플에서는 CS1614 오류가 발생합니다.

// CS1614.cs  
using System;  
  
// Both of the following classes are valid attributes with valid  
// names (MySpecial and MySpecialAttribute). However, because the lookup  
// rules for attributes involves auto-appending the 'Attribute' suffix  
// to the identifier, these two attributes become ambiguous; that is,  
// if you specify MySpecial, the compiler can't tell if you want  
// MySpecial or MySpecialAttribute.  
  
public class MySpecial : Attribute {  
   public MySpecial() {}  
}  
  
public class MySpecialAttribute : Attribute {  
   public MySpecialAttribute() {}  
}  
  
class MakeAWarning {  
   [MySpecial()] // CS1614  
                 // Ambiguous: MySpecial or MySpecialAttribute?  
   public static void Main() {  
   }  
  
   [@MySpecial()] // This isn't ambiguous, it binds to the first attribute above.  
   public static void NoWarning() {  
   }  
  
   [MySpecialAttribute()] // This isn't ambiguous, it binds to the second attribute above.  
   public static void NoWarning2() {  
   }  
  
   [@MySpecialAttribute()] // This is also legal.  
   public static void NoWarning3() {  
   }  
}