summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Runtime/Reliability
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Runtime/Reliability')
-rw-r--r--src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs44
-rw-r--r--src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs32
-rw-r--r--src/mscorlib/src/System/Runtime/Reliability/ReliabilityContractAttribute.cs67
3 files changed, 143 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs b/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs
new file mode 100644
index 0000000000..2524aaaecb
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs
@@ -0,0 +1,44 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//
+/*============================================================
+**
+**
+**
+** Deriving from this class will cause any finalizer you define to be critical
+** (i.e. the finalizer is guaranteed to run, won't be aborted by the host and is
+** run after the finalizers of other objects collected at the same time).
+**
+** You must possess UnmanagedCode permission in order to derive from this class.
+**
+**
+===========================================================*/
+
+using System;
+using System.Security.Permissions;
+using System.Runtime.InteropServices;
+
+namespace System.Runtime.ConstrainedExecution
+{
+#if !FEATURE_CORECLR
+ [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)]
+#endif
+ [System.Runtime.InteropServices.ComVisible(true)]
+ public abstract class CriticalFinalizerObject
+ {
+ #if FEATURE_CORECLR
+ [System.Security.SecuritySafeCritical] // auto-generated
+ #endif
+ [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
+ protected CriticalFinalizerObject()
+ {
+ }
+
+ [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
+ ~CriticalFinalizerObject()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs b/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs
new file mode 100644
index 0000000000..d9774d636b
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Reliability/PrePrepareMethodAttribute.cs
@@ -0,0 +1,32 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//
+/*============================================================
+**
+**
+** Purpose: Serves as a hint to ngen that the decorated method
+** (and its statically determinable call graph) should be
+** prepared (as for Constrained Execution Region use). This
+** is primarily useful in the scenario where the method in
+** question will be prepared explicitly at runtime and the
+** author of the method knows this and wishes to avoid the
+** overhead of runtime preparation.
+**
+**
+===========================================================*/
+namespace System.Runtime.ConstrainedExecution
+{
+ using System;
+ using System.Runtime.InteropServices;
+
+ [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
+
+ public sealed class PrePrepareMethodAttribute : Attribute
+ {
+ public PrePrepareMethodAttribute()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Runtime/Reliability/ReliabilityContractAttribute.cs b/src/mscorlib/src/System/Runtime/Reliability/ReliabilityContractAttribute.cs
new file mode 100644
index 0000000000..4a14e5733c
--- /dev/null
+++ b/src/mscorlib/src/System/Runtime/Reliability/ReliabilityContractAttribute.cs
@@ -0,0 +1,67 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//
+/*============================================================
+**
+**
+**
+** Purpose: Defines a publically documentable contract for
+** reliability between a method and its callers, expressing
+** what state will remain consistent in the presence of
+** failures (ie async exceptions like thread abort) and whether
+** the method needs to be called from within a CER.
+**
+**
+===========================================================*/
+
+namespace System.Runtime.ConstrainedExecution {
+ using System.Runtime.InteropServices;
+ using System;
+
+ // **************************************************************************************************************************
+ //
+ // Note that if you change either of the enums below or the constructors, fields or properties of the custom attribute itself
+ // you must also change the logic and definitions in vm\ConstrainedExecutionRegion.cpp to match.
+ //
+ // **************************************************************************************************************************
+
+ [Serializable]
+ public enum Consistency : int
+ {
+ MayCorruptProcess = 0,
+ MayCorruptAppDomain = 1,
+ MayCorruptInstance = 2,
+ WillNotCorruptState = 3,
+ }
+
+ [Serializable]
+ public enum Cer : int
+ {
+ None = 0,
+ MayFail = 1, // Might fail, but the method will say it failed
+ Success = 2,
+ }
+
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Interface /* | AttributeTargets.Delegate*/, Inherited = false)]
+ public sealed class ReliabilityContractAttribute : Attribute
+ {
+ private Consistency _consistency;
+ private Cer _cer;
+
+ public ReliabilityContractAttribute(Consistency consistencyGuarantee, Cer cer)
+ {
+ _consistency = consistencyGuarantee;
+ _cer = cer;
+ }
+
+ public Consistency ConsistencyGuarantee {
+ get { return _consistency; }
+ }
+
+ public Cer Cer {
+ get { return _cer; }
+ }
+ }
+}