If you don't want to hook up a custom listener, the easiest workaround is a custom Debug class, which substitutes the original one if the platform target is not the Framework:
#if !NETFRAMEWORK // this class is active for non-Framework platforms only
using System.Diagnostics;
using SystemDebug = System.Diagnostics.Debug;
namespace MyRootNamespace // so in your project this will hide the original Debug class
{
internal static class Debug
{
[Conditional("DEBUG")] // the call is emitted in Debug build only
internal static void Assert(bool condition, string message = null)
{
if (!condition)
Fail(message);
}
[Conditional("DEBUG")]
internal static void Fail(string message)
{
SystemDebug.WriteLine("Debug failure occurred - " + (message ?? "No message"));
if (!Debugger.IsAttached)
Debugger.Launch(); // a similar dialog, without the message, though
else
Debugger.Break(); // if debugger is already attached, we break here
}
[Conditional("DEBUG")]
internal static void WriteLine(string message) => SystemDebug.WriteLine(message);
// and if you use other methods from Debug, define also them here...
}
}
#endif