The Labs \ Source Viewer \ SSCLI \ System.Runtime.ConstrainedExecution \ Consistency

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  ReliabilityContractAttribute
  18. **
  19. **
  20. ** Purpose: Defines a publically documentable contract for
  21. ** reliability between a method and its callers, expressing
  22. ** what state will remain consistent in the presence of
  23. ** failures (ie async exceptions like thread abort) and whether
  24. ** the method needs to be called from within a CER.
  25. **
  26. **
  27. ===========================================================*/
  28. using System.Runtime.InteropServices;
  29. namespace System.Runtime.ConstrainedExecution
  30. {
  31.    
  32.     // **************************************************************************************************************************
  33.     //
  34.     // Note that if you change either of the enums below or the constructors, fields or properties of the custom attribute itself
  35.     // you must also change the logic and definitions in vm\ConstrainedExecutionRegion.cpp to match.
  36.     //
  37.     // **************************************************************************************************************************
  38.    
  39.     [Serializable()]
  40.     public enum Consistency : int
  41.     {
  42.         MayCorruptProcess = 0,
  43.         MayCorruptAppDomain = 1,
  44.         MayCorruptInstance = 2,
  45.         WillNotCorruptState = 3
  46.     }
  47.    
  48.     [Serializable()]
  49.     public enum Cer : int
  50.     {
  51.         None = 0,
  52.         MayFail = 1,
  53.         // Might fail, but the method will say it failed
  54.         Success = 2
  55.     }
  56.    
  57.         /* | AttributeTargets.Delegate*/    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Interface, Inherited = false)]
  58.     public sealed class ReliabilityContractAttribute : Attribute
  59.     {
  60.         private Consistency _consistency;
  61.         private Cer _cer;
  62.        
  63.         public ReliabilityContractAttribute(Consistency consistencyGuarantee, Cer cer)
  64.         {
  65.             _consistency = consistencyGuarantee;
  66.             _cer = cer;
  67.         }
  68.        
  69.         public Consistency ConsistencyGuarantee {
  70.             get { return _consistency; }
  71.         }
  72.        
  73.         public Cer Cer {
  74.             get { return _cer; }
  75.         }
  76.     }
  77. }

Developer Fusion