Clear stack trace in. NET/. NET Core
Stack tracing is one of the most important tools used to diagnose problems in exception-based languages. In some cases, developers can only get a brief error message and stack trace, especially when personal identifiable information (PII) limits the content of log records.
With the emergence of the task parallel Library (TPL) and The async/await functions that follow, stack tracing becomes increasingly difficult to understand. It is not uncommon to hide valid information.
In fact, this improvement should not be underestimated. In earlier versions of. NET 4.5 and before the introduction of the ExceptionDispatchInfo class, stack tracing cannot cross asynchronous boundaries, and developers will have to explore internal exceptions in depth. However, the research work is far more than that.
Illyriad game developer Ben Adams improved stack tracking in. NET Core 2.1. His work is mainly concentrated in the following areas:
- Eliminate noise caused by async/await alarms;
- Shows which method Overloading is called in asynchronous or iterator context;
At the same time, Anirudh Agnihotry updated the KeyNotFoundException used by Dictionary/ConcurrentDictionary to identify which keyword has not been found, which was a major headache for. NET developers to return to Version 1.0.
If you are already using the. NET Framework, or you do not want to wait for. NET Core 2.1, you can call the Ben. Demystifier library to use the work of Ben. This method can go beyond the functions that can be met after. NET Core is updated, and make the stack trace code closer to the original C # code for better readability. (For. NET Core, this is not one of the optional methods, because the C # keyword appears in the VB or F # stack trace ).
. NET Core is issued under the MIT license. Ben. Demystifier adopts Apache license.
Cleaner Stack Traces in. NET/. NET Core