From 37135d5e065199a8ac83d960fa7f93034ff1ef7d Mon Sep 17 00:00:00 2001 From: grokys Date: Wed, 5 Feb 2014 02:39:33 +0100 Subject: [PATCH] Make our simple Contract class throw an exception. --- Perspex/Contract.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Perspex/Contract.cs b/Perspex/Contract.cs index 82edb5af63..1550c098dd 100644 --- a/Perspex/Contract.cs +++ b/Perspex/Contract.cs @@ -8,8 +8,14 @@ namespace Perspex { internal static class Contract { - public static void Requires(bool condition) where TException : Exception + public static void Requires(bool condition) where TException : Exception, new() { +#if DEBUG + if (!condition) + { + throw new TException(); + } +#endif } } }