diff options
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs')
-rw-r--r-- | src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs index 93d6c48701..76b15197f2 100644 --- a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs +++ b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs @@ -27,7 +27,6 @@ #else // CLR #define FEATURE_UNTRUSTED_CALLERS #define FEATURE_RELIABILITY_CONTRACTS -#define FEATURE_SERIALIZATION #endif using System; @@ -43,8 +42,8 @@ using System.Runtime.ConstrainedExecution; using System.Security; #endif -namespace System.Diagnostics.Contracts { - +namespace System.Diagnostics.Contracts +{ #region Attributes /// <summary> @@ -71,7 +70,8 @@ namespace System.Diagnostics.Contracts { _typeWithContracts = typeContainingContracts; } - public Type TypeContainingContracts { + public Type TypeContainingContracts + { get { return _typeWithContracts; } } } @@ -90,7 +90,8 @@ namespace System.Diagnostics.Contracts { _typeIAmAContractFor = typeContractsAreFor; } - public Type TypeContractsAreFor { + public Type TypeContractsAreFor + { get { return _typeIAmAContractFor; } } } @@ -176,7 +177,8 @@ namespace System.Diagnostics.Contracts { public ContractVerificationAttribute(bool value) { _value = value; } - public bool Value { + public bool Value + { get { return _value; } } } @@ -197,7 +199,8 @@ namespace System.Diagnostics.Contracts { _publicName = name; } - public String Name { + public String Name + { get { return _publicName; } } } @@ -247,19 +250,23 @@ namespace System.Diagnostics.Contracts { _value = value; } - public String Category { + public String Category + { get { return _category; } } - public String Setting { + public String Setting + { get { return _setting; } } - public bool Enabled { + public bool Enabled + { get { return _enabled; } } - public String Value { + public String Value + { get { return _value; } } } @@ -296,7 +303,8 @@ namespace System.Diagnostics.Contracts { #endif public static void Assume(bool condition) { - if (!condition) { + if (!condition) + { ReportFailure(ContractFailureKind.Assume, null, null, null); } } @@ -316,7 +324,8 @@ namespace System.Diagnostics.Contracts { #endif public static void Assume(bool condition, String userMessage) { - if (!condition) { + if (!condition) + { ReportFailure(ContractFailureKind.Assume, userMessage, null, null); } } @@ -630,8 +639,8 @@ namespace System.Diagnostics.Contracts { public static bool ForAll(int fromInclusive, int toExclusive, Predicate<int> predicate) { if (fromInclusive > toExclusive) -#if INSIDE_CLR - throw new ArgumentException(Environment.GetResourceString("Argument_ToExclusiveLessThanFromExclusive")); +#if CORECLR + throw new ArgumentException(SR.Argument_ToExclusiveLessThanFromExclusive); #else throw new ArgumentException("fromInclusive must be less than or equal to toExclusive."); #endif @@ -690,8 +699,8 @@ namespace System.Diagnostics.Contracts { public static bool Exists(int fromInclusive, int toExclusive, Predicate<int> predicate) { if (fromInclusive > toExclusive) -#if INSIDE_CLR - throw new ArgumentException(Environment.GetResourceString("Argument_ToExclusiveLessThanFromExclusive")); +#if CORECLR + throw new ArgumentException(SR.Argument_ToExclusiveLessThanFromExclusive); #else throw new ArgumentException("fromInclusive must be less than or equal to toExclusive."); #endif @@ -769,7 +778,8 @@ namespace System.Diagnostics.Contracts { #endregion } - public enum ContractFailureKind { + public enum ContractFailureKind + { Precondition, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Postcondition")] Postcondition, @@ -779,8 +789,6 @@ namespace System.Diagnostics.Contracts { Assert, Assume, } - - } // Note: In .NET FX 4.5, we duplicated the ContractHelper class in the System.Runtime.CompilerServices |