ObsoleteAttribute.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. /*============================================================
  5. **
  6. **
  7. **
  8. ** Purpose: Attribute for functions, etc that will be removed.
  9. **
  10. **
  11. ===========================================================*/
  12. using System;
  13. namespace System
  14. {
  15. // This attribute is attached to members that are not to be used any longer.
  16. // Message is some human readable explanation of what to use
  17. // Error indicates if the compiler should treat usage of such a method as an
  18. // error. (this would be used if the actual implementation of the obsolete
  19. // method's implementation had changed).
  20. //
  21. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
  22. AttributeTargets.Interface | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate
  23. , Inherited = false)]
  24. public sealed class ObsoleteAttribute : Attribute
  25. {
  26. private string _message;
  27. private bool _error;
  28. public ObsoleteAttribute()
  29. {
  30. _message = null;
  31. _error = false;
  32. }
  33. public ObsoleteAttribute(string message)
  34. {
  35. _message = message;
  36. _error = false;
  37. }
  38. public ObsoleteAttribute(string message, bool error)
  39. {
  40. _message = message;
  41. _error = error;
  42. }
  43. public string Message
  44. {
  45. get { return _message; }
  46. }
  47. public bool IsError
  48. {
  49. get { return _error; }
  50. }
  51. }
  52. }