forked from VsVim/VsVim
/
Contract.cs
39 lines (35 loc) · 1.07 KB
/
Contract.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Diagnostics;
namespace EditorUtils
{
internal static class Contract
{
[Serializable]
internal sealed class ContractException : Exception
{
internal ContractException() { }
internal ContractException(string message) : base(message) { }
internal ContractException(string message, Exception inner) : base(message, inner) { }
internal ContractException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
}
internal static void Fail()
{
Requires(false);
}
internal static void Requires(bool condition)
{
if (!condition)
{
throw new ContractException();
}
}
[Conditional("DEBUG")]
internal static void Assert(bool condition)
{
Requires(condition);
}
}
}