dlr bug
[mcs.git] / docs / ecma334 / 24.4.3.xml
blob311a646de4d9386126ee2bfce3334ec390990906
1 <?xml version="1.0"?>
2 <clause number="24.4.3" title="The Obsolete attribute">
3   <paragraph>The attribute Obsolete is used to mark types and members of types that should no longer be used. <code_example><![CDATA[
4 using System;  
5 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |  
6 AttributeTargets.Enum | AttributeTargets.Interface |  
7 AttributeTargets.Delegate | AttributeTargets.Method |  
8 AttributeTargets.Constructor | AttributeTargets.Property |  
9 AttributeTargets.Field | AttributeTargets.Event)]  
10 public class ObsoleteAttribute: Attribute  
11 {  
12    public ObsoleteAttribute() {...}  
13    public ObsoleteAttribute(string message) {...}  
14    public ObsoleteAttribute(string message, bool error) {...}  
15    public string Message { get {...} }  
16    public bool IsError{ get {...} }  
17 }  
18 ]]></code_example></paragraph>
19   <paragraph>If a program uses a type or member that is decorated with the Obsolete attribute, then the compiler shall issue a warning or error in order to alert the developer, so the offending code can be fixed. Specifically, the compiler shall issue a warning if no error parameter is provided, or if the error parameter is provided and has the value false. The compiler shall issue a compile-time error if the error parameter is specified and has the value true. </paragraph>
20   <paragraph>
21     <example>[Example: In the example <code_example><![CDATA[
22 [Obsolete("This class is obsolete; use class B instead")]  
23 class A  
24 {  
25    public void F() {}  
26 }  
27 class B  
28 {  
29    public void F() {}  
30 }  
31 class Test  
32 {  
33    static void Main() {  
34       A a = new A(); // warning  
35       a.F();  
36    }  
37 }  
38 ]]></code_example>the class A is decorated with the Obsolete attribute. Each use of A in Main results in a warning that includes the specified message, &quot;This class is obsolete; use class B instead.&quot; end example]</example>
39     <table_line/>
40   </paragraph>
41 </clause>