PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/Common/Auxiliary/DebugVerify.cs

#
C# | 59 lines | 53 code | 6 blank | 0 comment | 3 complexity | d4405a1d4b8d4c522399f3a1c14684d6 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Diagnostics;
 6using System.Windows;
 7
 8namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
 9{
10	internal static class DebugVerify
11	{
12		[Conditional("DEBUG")]
13		[DebuggerStepThrough]
14		public static void Is(bool condition)
15		{
16			if (!condition)
17			{
18				throw new ArgumentException(Strings.Exceptions.AssertionFailed);
19			}
20		}
21
22		[Conditional("DEBUG")]
23		[DebuggerStepThrough]
24		public static void IsNotNaN(double d)
25		{
26			DebugVerify.Is(!Double.IsNaN(d));
27		}
28
29		[Conditional("DEBUG")]
30		[DebuggerStepThrough]
31		public static void IsNotNaN(Vector vec)
32		{
33			DebugVerify.IsNotNaN(vec.X);
34			DebugVerify.IsNotNaN(vec.Y);
35		}
36
37		[Conditional("DEBUG")]
38		[DebuggerStepThrough]
39		public static void IsNotNaN(Point point)
40		{
41			DebugVerify.IsNotNaN(point.X);
42			DebugVerify.IsNotNaN(point.Y);
43		}
44
45		[Conditional("DEBUG")]
46		[DebuggerStepThrough]
47		public static void IsFinite(double d)
48		{
49			DebugVerify.Is(!Double.IsInfinity(d) && !(Double.IsNaN(d)));
50		}
51
52		[Conditional("DEBUG")]
53		[DebuggerStepThrough]
54		public static void IsNotNull(object obj)
55		{
56			DebugVerify.Is(obj != null);
57		}
58	}
59}