Summary: - Define CSS_ASSERT_FAIL_ENABLED for P/Invoke (Visual Studio project already has it) - Pass managed delegate pointer to unmanaged side via P/Invoke. - CSSAssertFail will call the managed delegate when assert failed. - The delegate will throw managed exception. Reviewed By: emilsjolander Differential Revision: D3982084 fbshipit-source-id: 058a87c10ca89238362be4d8759cc00dd0c9b376
32 lines
827 B
C#
32 lines
827 B
C#
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
using System;
|
|
|
|
namespace Facebook.CSSLayout
|
|
{
|
|
internal static class CSSAssert
|
|
{
|
|
public delegate void FailFunc(string message);
|
|
|
|
private static bool _assertInitialized;
|
|
|
|
public static void Initialize()
|
|
{
|
|
if (!_assertInitialized)
|
|
{
|
|
Native.CSSAssertSetFailFunc((message) => {
|
|
throw new InvalidOperationException(message);
|
|
});
|
|
_assertInitialized = true;
|
|
}
|
|
}
|
|
}
|
|
}
|