dotnet / dotnet/wpf

`Debug.Assert` no longer shows a dialog prompt

Open
#3,346 6 comments 4 reactions 1 assignee Claimed by @ryalanms View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: **.NET Core 3.1 onwards**

* Have you experienced this same bug with .NET Framework?: **No**

**Problem description:**

`System.Diagnostics.Trace.Assert` and `System.Diagnostics.Debug.Assert` no longer trigger a dialog prompts in desktop apps. Instead apps silently silently crash unless have a debugger attached.

As discussed in https://github.com/dotnet/runtime/issues/40512, the assert behavior was changed in dotnet/coreclr#20764, and no longer raises a dialog.
https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.Debug/tests/DebugTestsUsingListeners.cs#L248-L303 illustrates how to implement a custom trace listener, which may act as a basis for a fix.

**Expected behavior:**

No crash, and assertion dialog must appear after assert.

**Minimal repro:**

1. Create new WPF Core project.
2. Put `System.Diagnostics.Debug.Assert(false, "test");` anywhere in the code, for example:
```cs
protected override void OnActivated(EventArgs e)
{
System.Diagnostics.Debug.Assert(false, "test");
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.