soygul/NBug — pull request #41 by DoctorDump (2014-09-17 08:42:23+00:00)
Title: Ability to create arbitrary exception stack traces in WinForms example

"Stack (use numbers for functions, comma for nested exception):" text
box added where a user can enter some random data that creates unique
exception stack with specified nesting level.

This is useful to test ability of crash report receiver to group similar reports to one bug and to separate different reports from others.

In previous implementation there was only two different stacks - one in CrashButton_Click and another one crash in lambda in a new thread.

Also there was no real test for inner exceptions. In the only one that existed inner exception was not thrown, it just was created and attached to another one, that is not as real things happen.

There is a little excess of RollStack, but I don't know an easy way how to solve this with few lines of code. The only easy way is [MethodImpl(MethodImplOptions.AggressiveInlining)], but it is supported only in .NET4.5. Anyway for test purposes any different stack is enough.

Example of new stack for "0987,6543" input:

System.Exception: Selected exception: 'UI Thread: System.Exception' was thrown.
at NBug.Examples.WinForms.MainForm.Three(Int32 index, String text, Exception e) in MainForm.cs:85
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:68
at NBug.Examples.WinForms.MainForm.Four(Int32 index, String text, Exception e) in MainForm.cs:87
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:69
at NBug.Examples.WinForms.MainForm.Five(Int32 index, String text, Exception e) in MainForm.cs:89
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:70
at NBug.Examples.WinForms.MainForm.Six(Int32 index, String text, Exception e) in MainForm.cs:91
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:71
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:55

System.Exception: 0987
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:74
at NBug.Examples.WinForms.MainForm.Seven(Int32 index, String text, Exception e) in MainForm.cs:93
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:72
at NBug.Examples.WinForms.MainForm.Eight(Int32 index, String text, Exception e) in MainForm.cs:95
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:73
at NBug.Examples.WinForms.MainForm.Nine(Int32 index, String text, Exception e) in MainForm.cs:97
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:74
at NBug.Examples.WinForms.MainForm.Zero(Int32 index, String text, Exception e) in MainForm.cs:79
at NBug.Examples.WinForms.MainForm.RollStack(Int32 index, String text, Exception e) in MainForm.cs:65
at NBug.Examples.WinForms.MainForm.CrashButton_Click(Object sender, EventArgs e) in MainForm.cs:125
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)