- ago
I'd like to check some invariants on the run. I used to apply `System.Diagnostics.Debug` for that. The code as follows

CODE:
public override void Execute(BarHistory bars, int idx) { System.Diagnostics.Debug.Assert(false); }


Should fail but it doesn't. Why?
0
388
Solved
6 Replies

Reply

Bookmark

Sort
- ago
#1
Probably because Wealth-Lab isn't running in debug mode?
0
- ago
#2
System.Diagnostics.Debug.Assert works only when DEBUG flag is set while building the project containing that code/call. The DEBUG compilation flag is generally set when you build your strategy project in Debug mode. It doesn't matter if WL8 is a Debug or Release build.

If your project is already built in Debug mode and you do not see it throwing an exception in the WL8 front-end, it might be because WL8 is catching the exception and suppressing/ignoring it.
0
Best Answer
- ago
#3
Thanks for the clarification. What's the proper way to assert conditions in WL code?
0
- ago
#4
WLHost.Instance.AddLogItem(...WLColor.Red...)
0
- ago
#5
DrKoch, I tried

CODE:
WLHost.Instance.AddLogItem("my-strategy", "msg", WLColor.Red);


Where is the output exactly? Don't see those red lines under `Debug Log` tab.
0
- ago
#6
Tools > Log Viewer.
1

Reply

Bookmark

Sort