Share via


컴파일러 오류 CS1614

업데이트: 2007년 11월

오류 메시지

'name'은(는) 'attribute1'과(와) 'attribute2' 사이에서 모호합니다. '@attribute' 또는 'attributeAttribute'를 사용하십시오.
'name' is ambiguous; between 'attribute1' and 'attribute2'. use either '@attribute' or 'attributeAttribute'

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

편의상 C# 컴파일러에서는 ExampleAttribute를 간단히 [Example]로 지정할 수 있습니다. 그러나 ExampleAttribute와 함께 Example이라는 특성 클래스가 있을 경우에는 모호성이 발생합니다. 이는 [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() {
   }
}