DisplayHelper 1.5.2

dotnet add package DisplayHelper --version 1.5.2                
NuGet\Install-Package DisplayHelper -Version 1.5.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DisplayHelper" Version="1.5.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DisplayHelper --version 1.5.2                
#r "nuget: DisplayHelper, 1.5.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DisplayHelper as a Cake Addin
#addin nuget:?package=DisplayHelper&version=1.5.2

// Install DisplayHelper as a Cake Tool
#tool nuget:?package=DisplayHelper&version=1.5.2                

DisplayHelper

DisplayHelper is a small .NET library designed to simplify the display of objects and text. Currently it can be used as-is with console applications and Windows Forms applications. However, it is relatively straight-forward to extend the base DisplayHelper class for use in other applications.

The DisplayHelper library targets .NET Framework 2.0 to make it as broadly usable as possible.

Functionality Provided by DisplayHelper

Displaying Objects

The DisplayHelper uses reflection to display the values of an object's properties and fields. It will recurse down through the object graph, displaying the values of sub-properties (properties of objects that are properties of other objects), sub-sub-properties, etc.

The DisplayHelper has two mechanisms to prevent endless recursion:

  1. It will not follow direct or indirect circular references (for example, if a parent object has a Child property that has a Parent property pointing back to the original parent object). Instead it displays a message it has encountered a circular reference and skips the property involved, continuing to display details of other properties;

  2. It tracks how deep the recursion gets. It currently has a hard-coded maximum recursion depth of 5: If the same type of object appears on 5 different levels within the object graph the DisplayHelper will terminate its walk through the graph. In that case a message will be displayed to inform the user the DisplayHelper is terminating without having viewed the whole object graph, and the reason for the early termination.

In addition to recursing down through an object's properties, the DisplayHelper can display the properties of lists or arrays of objects.

The DisplayHelper will display messages if an object or property is null, or if a collection has no elements.

Static properties and fields of an object are not displayed. This is because static members are not ordinarily accessible from an object; normally they are accessed from the class, not from an instance of that type.

Displaying Exceptions

The DisplayHelper will display the type of an exception and the exception message. It will recurse down through any inner exceptions, and inner-inner exceptions, etc, displaying the details of each.

Displaying Data Tables

The DisplayHelper will display the values in every cell of every row of a specified data table. It can handle empty data tables and data tables that are set to null.

Displaying XML and JSON Text

The DisplayHelper will add line breaks and indents when displaying XML and JSON text to make them more readable.

Displaying Text

The DisplayHelper has several helper methods for displaying text. These are most useful in Console applications, although they can be used in Windows Forms applications as well:

  • Display indented text, with the indent width specified;

  • Display headed text, with the text in the form Header: My text. The indent level of the text can be specified;

  • Display numbered text, of the form: 2) My text. The indent level of the text can be specified;

  • Display titles and sub-titles, where the text is underlined. The only difference between a title and sub-title is the style of the underline.

Get Display-friendly Text

The DisplayHelper includes a helper method for converting text to a display-friendly format. Specifically, if the string is null, empty or blank it will be converted to a user-friendly string, such as "[NULL]", "[EMPTY STRING]" or "[BLANK STRING]".

Get Exception Details

In addition to displaying exception details the DisplayHelper includes a helper method that returns exception details as a string. This may be useful for logging. Similar to displaying the exception details, the string returned from the helper method includes the type of the exception and the exception message. It also recursively includes the details of any inner exceptions and inner-inner exceptions, etc.

Product Compatible and additional computed target framework versions.
.NET Framework net20 is compatible.  net35 was computed.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.2 538 3/11/2022
1.5.1 461 3/11/2022
1.5.0 468 3/11/2022
1.4.0 486 3/11/2022
1.3.1 639 2/15/2020
1.3.0 855 11/17/2019
1.2.1 1,151 2/3/2017
1.2.0 1,085 1/8/2017
1.1.0 1,259 9/2/2016
1.0.0 1,528 8/27/2016

DisplayHelper: Add static GetDisplayText and GetExceptionMessage methods.