1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Microsoft Public License. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Microsoft Public License, please send an email to
8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Microsoft Public License.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
17 using System; using Microsoft;
20 using System.Collections.Generic;
21 using System.Diagnostics;
24 namespace System.Dynamic {
26 namespace Microsoft.Scripting {
28 internal static class Assert {
30 internal static Exception Unreachable {
32 Debug.Assert(false, "Unreachable");
33 return new InvalidOperationException("Code supposed to be unreachable");
37 [Conditional("DEBUG")]
38 internal static void NotNull(object var) {
39 Debug.Assert(var != null);
42 [Conditional("DEBUG")]
43 internal static void NotNull(object var1, object var2) {
44 Debug.Assert(var1 != null && var2 != null);
47 [Conditional("DEBUG")]
48 internal static void NotNull(object var1, object var2, object var3) {
49 Debug.Assert(var1 != null && var2 != null && var3 != null);
52 [Conditional("DEBUG")]
53 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
54 internal static void NotNull(object var1, object var2, object var3, object var4) {
55 Debug.Assert(var1 != null && var2 != null && var3 != null && var4 != null);
58 [Conditional("DEBUG")]
59 internal static void NotEmpty(string str) {
60 Debug.Assert(!String.IsNullOrEmpty(str));
63 [Conditional("DEBUG")]
64 internal static void NotEmpty<T>(ICollection<T> array) {
65 Debug.Assert(array != null && array.Count > 0);
68 [Conditional("DEBUG")]
69 internal static void NotNullItems<T>(IEnumerable<T> items) where T : class {
70 Debug.Assert(items != null);
71 foreach (object item in items) {
72 Debug.Assert(item != null);
76 [Conditional("DEBUG")]
77 internal static void IsTrue(Func<bool> predicate) {
78 ContractUtils.RequiresNotNull(predicate, "predicate");
79 Debug.Assert(predicate());