Clear stack trace in. NET/. NET Core

Source: Internet
Author: User

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:

  1. Eliminate noise caused by async/await alarms;
  2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.