Mono Class Library: System NamespaceSystem.ObsoleteAttribute Class |
See Also: ObsoleteAttribute Members
System.Object
System.Attribute
System.ObsoleteAttribute
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
Note:[Edit]Marking an item as obsolete provides consumers of that item the information that the item will be not be available in future versions of the assembly in which it is contained. A ObsoleteAttribute has a ObsoleteAttribute.Message property that can be used to suggest alternative ways of obtaining the functionality provided by the item, i.e. a workaround. This class also has a ObsoleteAttribute.IsError property that designates whether a compiler will treat usage of the obsolete item as an error. If this property is false, the compiler will issue a warning if the obsolete item is used and the compiler supports the generation of such warnings.
This attribute can be applied to any valid attribute target except assemblies, parameters, and return values. For a complete list of valid attribute targets, see AttributeTargets .
The following example demonstrates the usage of ObsoleteAttribute to generate a compile-time warning.
C# Example using System; public class ObsoleteAttributeExample { [ObsoleteAttribute("OldMethod is being removed: use NewMethod in future versions.")] public static void OldMethod() { //Execute some code here } public static void Main() { OldMethod(); } }An example compile-time result is
ObsoleteAttributeExample.cs(8,4): warning CS0618: 'ObsoleteAttributeExample.OldMethod()' is obsolete: 'OldMethod is being removed: use NewMethod in future versions.'
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0