update MEF to preview 9
[mcs.git] / class / System.ComponentModel.Composition / src / ComponentModel / Microsoft / Internal / Assumes.cs
blob7b1dd6f7975a95ed1ad424dc0d109b63c76e7866
1 // -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
4 using System;
5 using System.ComponentModel;
6 using System.Diagnostics;
7 using System.Diagnostics.CodeAnalysis;
8 using System.Globalization;
9 using System.Runtime.Serialization;
11 namespace Microsoft.Internal
13 internal static partial class Assumes
15 [DebuggerStepThrough]
16 internal static void NotNull<T>(T value)
17 where T : class
19 IsTrue(value != null);
22 [DebuggerStepThrough]
23 internal static void NotNull<T1, T2>(T1 value1, T2 value2)
24 where T1 : class
25 where T2 : class
27 NotNull(value1);
28 NotNull(value2);
31 [DebuggerStepThrough]
32 internal static void NotNull<T1, T2, T3>(T1 value1, T2 value2, T3 value3)
33 where T1 : class
34 where T2 : class
35 where T3 : class
37 NotNull(value1);
38 NotNull(value2);
39 NotNull(value3);
42 [DebuggerStepThrough]
43 internal static void NotNullOrEmpty<T>(T[] values)
45 Assumes.NotNull(values);
46 Assumes.IsTrue(values.Length > 0);
49 [DebuggerStepThrough]
50 internal static void NotNullOrEmpty(string value)
52 NotNull(value);
53 IsTrue(value.Length > 0);
56 [DebuggerStepThrough]
57 internal static void Null<T>(T value)
58 where T : class
60 IsTrue(value == null);
63 [DebuggerStepThrough]
64 internal static void IsFalse(bool condition)
66 if (condition)
68 Fail(null);
72 [DebuggerStepThrough]
73 internal static void IsTrue(bool condition)
75 if (!condition)
77 Fail(null);
81 [DebuggerStepThrough]
82 internal static void IsTrue(bool condition, [Localizable(false)]string message)
84 if (!condition)
86 Fail(message);
90 [DebuggerStepThrough]
91 internal static void Fail([Localizable(false)]string message)
93 throw new InternalErrorException(message);
96 [DebuggerStepThrough]
97 internal static T NotReachable<T>()
99 throw new InternalErrorException("Code path should never be reached!");