|
|
|
@ -1,6 +1,8 @@ |
|
|
|
// Copyright (c) The Perspex Project. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
|
|
|
namespace Perspex |
|
|
|
{ |
|
|
|
using System; |
|
|
|
@ -22,14 +24,13 @@ namespace Perspex |
|
|
|
/// The exception to throw if <paramref name="condition"/> is false.
|
|
|
|
/// </typeparam>
|
|
|
|
/// <param name="condition">The precondition.</param>
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void Requires<TException>(bool condition) where TException : Exception, new() |
|
|
|
{ |
|
|
|
#if DEBUG
|
|
|
|
if (!condition) |
|
|
|
{ |
|
|
|
throw new TException(); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|