Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@maryamariyan
Copy link

@maryamariyan maryamariyan commented Nov 2, 2018

Note:
@jkotas:

  • I added back s_ShowDialog delegate for use only in tests to exercise the code path on DefaultTraceListener.Fail and DebugProvider.Fail.

Arguably, as mentioned by you earlier in https://github.com/dotnet/corefx/issues/33110 and as illustrated here, Trace Listeners can be used to show a custom dialog.
As a result, I couldn't find enough reason for adding any public API for ShowDialog.

This PR helps link Debug.Assert and Debug.Fail with Trace Listeners.

corefx PR: dotnet/corefx#33212
cc: @jkotas @danmosemsft @eerhardt

UPDATE

  • Renamed ShowDialog to FailCore since in .NET Core it is not really showing dialog

@maryamariyan maryamariyan self-assigned this Nov 2, 2018
@maryamariyan maryamariyan changed the title Allows Debug.Fail to go through Trace Listeners and Adds public ShowDialogCore delegate Allows Debug.Fail to go through Trace Listeners Nov 2, 2018
{
if (s_ShowDialog != null)
{
s_ShowDialog(stackTrace, message, detailMessage, errorSource);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this can be set to null, there's a potential race condition here, and s_showDialog should be stored into a local first and then that local checked and used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s_ShowDialog is a hook for our existing internal tests only.

string stackTrace;
try
{
stackTrace = new StackTrace(0, true).ToString(System.Diagnostics.StackTrace.TraceFormat.Normal);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the extra stackframes between the user code and this place show up in the stacktrace now?

Copy link
Author

@maryamariyan maryamariyan Nov 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they don't. Only shows up until the user code, the line that calls Debug.Fail or Trace.Fail.

That's what we want right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.

@maryamariyan
Copy link
Author

@dotnet-bot test CentOS7.1 x64 Debug Innerloop Build

@maryamariyan maryamariyan merged commit 86ab37c into dotnet:master Nov 2, 2018
@maryamariyan maryamariyan deleted the debug-fail branch November 2, 2018 20:42
dotnet-maestro-bot pushed a commit to dotnet-maestro-bot/corefx that referenced this pull request Nov 5, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
dotnet-maestro-bot pushed a commit to dotnet-maestro-bot/corert that referenced this pull request Nov 5, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Nov 5, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
MichalStrehovsky pushed a commit to dotnet/corert that referenced this pull request Nov 8, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
A-And pushed a commit to A-And/coreclr that referenced this pull request Nov 20, 2018
@RussKie
Copy link

RussKie commented Aug 13, 2020

As a result, I couldn't find enough reason for adding any public API for ShowDialog.

I think this completely overlooks and ultimately breaks the developer experience - irrespective of a stack (web or desktop, Windows or not) a developer should be presented with an assert popup, if it gets hit. Right now the debug experience for .NET Core/.NET is totally broken, an app just crashes, if it is launched outside a debugger.

A VS experience isn't better either:
image

VS Code is offering a better DevEx, but it can't be used to develop desktop apps:
image

@danmoseley
Copy link
Member

I interpreted the comment to mean a new API should not be necessary in order to get Debug.Assert to work, not that it wasn't important to get it to work.

@jkotas
Copy link
Member

jkotas commented Aug 13, 2020

@RussKie Thank you for bringing it up. I have opened dotnet/runtime#40793

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants