Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Replace Contract.Assumes and Contract.Assert with Debug.Assert/Debug.…
Browse files Browse the repository at this point in the history
…Fail (#14136)

* Remove use of Contract.Assert and Contract.Assumes in favor of Debug.xx

* Remove dead IA64 blocks

* Remove use of Contract.Requires in favor of Debug.Assert

* Remove Contract.EndContractBlock()

* Dead comments

* Straggler EndcontractBlock

* Remove all Contract.Ensures

* Remove [Pure] attribute and using statements

* Remove using statements for M.D.Contracts.Internal.Contract

* Rmove CA suppressions for Contracts

* Remove M.D.Contracts.Internal stub

* Comments and extra using

* Revert accidentallly removed #if

* Unix build

* Merge Math*

* Fix assert not updated since desktop

* Asserts add no value: remove

* Avoid infinite recursion in StringBuilder assert

* Remove asserts that should be public parameter validation

* Fix comment

* Remove blank line after open curly

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
danmoseley authored and dotnet-bot committed Sep 27, 2017
1 parent bbdec85 commit 6355626
Show file tree
Hide file tree
Showing 100 changed files with 13 additions and 914 deletions.
1 change: 0 additions & 1 deletion src/System.Private.CoreLib/shared/System/Boolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
**
===========================================================*/

using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
Expand Down
4 changes: 0 additions & 4 deletions src/System.Private.CoreLib/shared/System/Byte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,24 @@ private static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, NumberFor
[Pure]
public override String ToString()
{
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}

[Pure]
public String ToString(String format)
{
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.CurrentInfo);
}

[Pure]
public String ToString(IFormatProvider provider)
{
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}

[Pure]
public String ToString(String format, IFormatProvider provider)
{
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.GetInstance(provider));
}

Expand Down
25 changes: 0 additions & 25 deletions src/System.Private.CoreLib/shared/System/Char.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ public int CompareTo(Char value)
[Pure]
public override String ToString()
{
Contract.Ensures(Contract.Result<String>() != null);
return Char.ToString(m_value);
}

[Pure]
public String ToString(IFormatProvider provider)
{
Contract.Ensures(Contract.Result<String>() != null);
return Char.ToString(m_value);
}

Expand All @@ -182,7 +180,6 @@ public static char Parse(String s)
{
throw new ArgumentNullException(nameof(s));
}
Contract.EndContractBlock();

if (s.Length != 1)
{
Expand Down Expand Up @@ -405,7 +402,6 @@ public static char ToUpper(char c, CultureInfo culture)
{
if (culture == null)
throw new ArgumentNullException(nameof(culture));
Contract.EndContractBlock();
return culture.TextInfo.ToUpper(c);
}

Expand Down Expand Up @@ -438,7 +434,6 @@ public static char ToLower(char c, CultureInfo culture)
{
if (culture == null)
throw new ArgumentNullException(nameof(culture));
Contract.EndContractBlock();
return culture.TextInfo.ToLower(c);
}

Expand Down Expand Up @@ -562,7 +557,6 @@ public static bool IsControl(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -580,7 +574,6 @@ public static bool IsDigit(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -597,7 +590,6 @@ public static bool IsLetter(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -619,7 +611,6 @@ public static bool IsLetterOrDigit(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -636,7 +627,6 @@ public static bool IsLower(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand Down Expand Up @@ -687,7 +677,6 @@ public static bool IsNumber(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand Down Expand Up @@ -716,7 +705,6 @@ public static bool IsPunctuation(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand Down Expand Up @@ -766,7 +754,6 @@ public static bool IsSeparator(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -792,7 +779,6 @@ public static bool IsSurrogate(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return (IsSurrogate(s[index]));
}

Expand Down Expand Up @@ -830,7 +816,6 @@ public static bool IsSymbol(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -848,7 +833,6 @@ public static bool IsUpper(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
if (IsLatin1(c))
{
Expand All @@ -870,7 +854,6 @@ public static bool IsWhiteSpace(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();

if (IsLatin1(s[index]))
{
Expand All @@ -897,7 +880,6 @@ public static UnicodeCategory GetUnicodeCategory(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
if (IsLatin1(s[index]))
{
return (GetLatin1UnicodeCategory(s[index]));
Expand All @@ -918,7 +900,6 @@ public static double GetNumericValue(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return CharUnicodeInfo.GetNumericValue(s, index);
}

Expand All @@ -943,7 +924,6 @@ public static bool IsHighSurrogate(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return (IsHighSurrogate(s[index]));
}

Expand All @@ -967,7 +947,6 @@ public static bool IsLowSurrogate(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return (IsLowSurrogate(s[index]));
}

Expand All @@ -985,7 +964,6 @@ public static bool IsSurrogatePair(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
if (index + 1 < s.Length)
{
return (IsSurrogatePair(s[index], s[index + 1]));
Expand Down Expand Up @@ -1024,7 +1002,6 @@ public static String ConvertFromUtf32(int utf32)
{
throw new ArgumentOutOfRangeException(nameof(utf32), SR.ArgumentOutOfRange_InvalidUTF32);
}
Contract.EndContractBlock();

if (utf32 < UNICODE_PLANE01_START)
{
Expand Down Expand Up @@ -1059,7 +1036,6 @@ public static int ConvertToUtf32(char highSurrogate, char lowSurrogate)
{
throw new ArgumentOutOfRangeException(nameof(lowSurrogate), SR.ArgumentOutOfRange_InvalidLowSurrogate);
}
Contract.EndContractBlock();
return (((highSurrogate - CharUnicodeInfo.HIGH_SURROGATE_START) * 0x400) + (lowSurrogate - CharUnicodeInfo.LOW_SURROGATE_START) + UNICODE_PLANE01_START);
}

Expand All @@ -1082,7 +1058,6 @@ public static int ConvertToUtf32(String s, int index)
{
throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
}
Contract.EndContractBlock();
// Check if the character at index is a high surrogate.
int temp1 = (int)s[index] - CharUnicodeInfo.HIGH_SURROGATE_START;
if (temp1 >= 0 && temp1 <= 0x7ff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Runtime.CompilerServices;
using System.Diagnostics.Contracts;

namespace System.Collections.Generic
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics.Contracts;

namespace System.Collections.Generic
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Diagnostics.Contracts;

namespace System.Collections.Generic
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Diagnostics.Contracts;

namespace System.Collections.Generic
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;

namespace System.Collections.Generic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics.Contracts;

namespace System.Collections.Generic
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;

namespace System.Collections.Generic
Expand Down
Loading

0 comments on commit 6355626

Please sign in to comment.