Desharp 1.2.15

Desharp - C#/VB .NET debuging utility to dump or log structured variables, exceptions, stack traces and much more into console, visual studio console, into html web response as floating window or into html/text log files on HDD.
Download and install Visual Studio code snippets for Desharp: https://github.com/debug-sharp/codesnippets
Dependencies .NET Framework >= 4.0.0.0 (Microsoft.CSharp, System, System.Configuration, System.Core, System.Data, System.Data.DataSetExtensions, System.Web, System.Web.Extensions, System.Xml)

There is a newer version of this package available.
See the version list below for details.

Requires NuGet 2.6 or higher.

Install-Package Desharp -Version 1.2.15
dotnet add package Desharp --version 1.2.15
<PackageReference Include="Desharp" Version="1.2.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Desharp --version 1.2.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Instalation

PM> Install-Package Desharp

Usage and examples

Code snippets

To use long Desharp calls more comfortable, install Visual Studio code snippets for desharp to create proper shortcuts
More info about code snippets for Visual Studio.

Dump/log any variable

C#:
using Desharp;
using System.Collections.Generic;

var list = new List<string>() { "a", "b", "c" };
Debug.Dump(list);  // print list by Console.WriteLine(); or append into html response as floating window
Debug.Log(list);   // store dumped list in debug.log or debug.html file on HDD
VB:
Imports Desharp
Imports System.Collections.Generic

Dim list As New List(Of String)() { "a", "b", "c" }
Debug.Dump(list)  ' print list by Console.WriteLine(); or append into html response as floating window
Debug.Log(list)   ' store dumped list in debug.log or debug.html file on HDD

Dumped list for both languages in debug output or console window:

[List<string>(3)]
   0: "a" [String(1)]
   1: "b" [String(1)]
   2: "c" [String(1)]

Dump/log Exception

C#:
try {
   throw new Exception("Something wrong!");
} catch (Exception e) {
   Debug.Dump(e);  // print exception by Console.WriteLine(); or append into html response as floating window
   Debug.Log(e);   // store dumped exception in exception.log or exception.html file on HDD
}
VB:
Try
   Throw New Exception("Something wrong!")
Catch e As Exception
   Debug.Dump(e)  ' print exception by Console.WriteLine(); or append into html response as floating window
   Debug.Log(e)   ' store dumped exception in exception.log or exception.html file on HDD
End Try

Dumped exception for both languages in debug output or console window:

System.Exception (Hash Code: 50632145):
   Message   : Something wrong!
   Time      : 2017-06-10 13:18:07:300
   Process ID: 7972
   Thread ID : 1
   File      : /Program.cs:8
   -------
       4 | namespace ExampleConsole {
       5 |     class Program {
       6 |         static void Main(string[] args) {
       7 |             try {
   ->  8 |                 throw new Exception("Something wrong!");
       9 |             } catch (Exception e) {
      10 |                 Debug.Dump(e);  // print exception by Console.WriteLine(); or append into html response as floating window
      11 |                 Debug.Log(e);   // store dumped exception in exception.log or exception.html file on HDD
      12 |             }
   -------
   Callstack: 
      ExampleConsole.Program.Main(String[] args) /Program.cs 8

Dump outputs

  • console window for console applications
  • Visual Studio console for Windows Forms or WPF applications
  • floating window in html response for web applications
  • special HTTP headers for FilePHP browser extension for web applications
  • file logs in text/html formats

Dump possibilities

You can dump or log:

  • any variables
    • primitive variables and it's primitive arrays like: char, int?[] and more
    • Lists, Arrays or Dictionaries (IList, IEnumerable, ICollection, IDictionary...)
    • database results (DataSet, DataTable, DataRow)
    • any custom class instances with rendered events targets and properties and fields values
    • anonymous objects
    • much more... you can try:-)
  • exceptions
    • all inner exceptions inside will be also dumped or logged

Dump additional info

All dump or log calls have automaticly rendered:

  • process/thread/request id
  • current time from DateTime.Now
  • callstack, where was Debug.Dump() or Debug.Log() used or where Exception happend
  • if exception has been caused by another exception (inner exceptions), there is rendered source exception object hash
  • if source code is possible by *.PDB file, there is rendered:
    • a few lines from source code, where was Debug.Dump() or Debug.Log() used or where Exception happend
  • if environment is web application, there is rendered:
    • request URL
    • all http request headers
    • client IP
  • if environment is web application, for dump browser output are rendered loaded assemblies

Configuration

You can configure by app.config/web.config or directly by calling Debug.Configure():

  • if debugging is enabled or not (enabled by default)
  • debug IPs to enable debugging only for list of client IPs (no ips by default)
  • logs directory (app root if not defined)
  • log files format:
    • text (*.log, by default)
    • html (*.html)
  • logging levels:
    • debug (by default)
    • exception
    • info
    • notice
    • warning
    • error
    • critical
    • alert
    • emergency
    • javascript
  • favourite editor to open files from html output by editor:// protocol (MSVS by default)

Instalation

PM> Install-Package Desharp

Usage and examples

Code snippets

To use long Desharp calls more comfortable, install Visual Studio code snippets for desharp to create proper shortcuts
More info about code snippets for Visual Studio.

Dump/log any variable

C#:
using Desharp;
using System.Collections.Generic;

var list = new List<string>() { "a", "b", "c" };
Debug.Dump(list);  // print list by Console.WriteLine(); or append into html response as floating window
Debug.Log(list);   // store dumped list in debug.log or debug.html file on HDD
VB:
Imports Desharp
Imports System.Collections.Generic

Dim list As New List(Of String)() { "a", "b", "c" }
Debug.Dump(list)  ' print list by Console.WriteLine(); or append into html response as floating window
Debug.Log(list)   ' store dumped list in debug.log or debug.html file on HDD

Dumped list for both languages in debug output or console window:

[List<string>(3)]
   0: "a" [String(1)]
   1: "b" [String(1)]
   2: "c" [String(1)]

Dump/log Exception

C#:
try {
   throw new Exception("Something wrong!");
} catch (Exception e) {
   Debug.Dump(e);  // print exception by Console.WriteLine(); or append into html response as floating window
   Debug.Log(e);   // store dumped exception in exception.log or exception.html file on HDD
}
VB:
Try
   Throw New Exception("Something wrong!")
Catch e As Exception
   Debug.Dump(e)  ' print exception by Console.WriteLine(); or append into html response as floating window
   Debug.Log(e)   ' store dumped exception in exception.log or exception.html file on HDD
End Try

Dumped exception for both languages in debug output or console window:

System.Exception (Hash Code: 50632145):
   Message   : Something wrong!
   Time      : 2017-06-10 13:18:07:300
   Process ID: 7972
   Thread ID : 1
   File      : /Program.cs:8
   -------
       4 | namespace ExampleConsole {
       5 |     class Program {
       6 |         static void Main(string[] args) {
       7 |             try {
   ->  8 |                 throw new Exception("Something wrong!");
       9 |             } catch (Exception e) {
      10 |                 Debug.Dump(e);  // print exception by Console.WriteLine(); or append into html response as floating window
      11 |                 Debug.Log(e);   // store dumped exception in exception.log or exception.html file on HDD
      12 |             }
   -------
   Callstack: 
      ExampleConsole.Program.Main(String[] args) /Program.cs 8

Dump outputs

  • console window for console applications
  • Visual Studio console for Windows Forms or WPF applications
  • floating window in html response for web applications
  • special HTTP headers for FilePHP browser extension for web applications
  • file logs in text/html formats

Dump possibilities

You can dump or log:

  • any variables
    • primitive variables and it's primitive arrays like: char, int?[] and more
    • Lists, Arrays or Dictionaries (IList, IEnumerable, ICollection, IDictionary...)
    • database results (DataSet, DataTable, DataRow)
    • any custom class instances with rendered events targets and properties and fields values
    • anonymous objects
    • much more... you can try:-)
  • exceptions
    • all inner exceptions inside will be also dumped or logged

Dump additional info

All dump or log calls have automaticly rendered:

  • process/thread/request id
  • current time from DateTime.Now
  • callstack, where was Debug.Dump() or Debug.Log() used or where Exception happend
  • if exception has been caused by another exception (inner exceptions), there is rendered source exception object hash
  • if source code is possible by *.PDB file, there is rendered:
    • a few lines from source code, where was Debug.Dump() or Debug.Log() used or where Exception happend
  • if environment is web application, there is rendered:
    • request URL
    • all http request headers
    • client IP
  • if environment is web application, for dump browser output are rendered loaded assemblies

Configuration

You can configure by app.config/web.config or directly by calling Debug.Configure():

  • if debugging is enabled or not (enabled by default)
  • debug IPs to enable debugging only for list of client IPs (no ips by default)
  • logs directory (app root if not defined)
  • log files format:
    • text (*.log, by default)
    • html (*.html)
  • logging levels:
    • debug (by default)
    • exception
    • info
    • notice
    • warning
    • error
    • critical
    • alert
    • emergency
    • javascript
  • favourite editor to open files from html output by editor:// protocol (MSVS by default)

Release Notes

https://github.com/debug-sharp/desharp/releases

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.3.0.3 48 9/26/2019
1.3.0.2 40 9/26/2019
1.3.0.1 41 9/26/2019
1.3.0 38 9/25/2019
1.2.15 39 9/20/2019
1.2.12 1,835 1/18/2019
1.2.11 5,035 12/11/2017
1.2.9 385 11/28/2017
1.2.8 456 11/7/2017
1.2.4 983 6/14/2017
1.2.3 345 6/12/2017
1.1.6 305 6/5/2017
1.1.5 277 6/4/2017
1.0.1 297 3/26/2017
1.0.0 303 3/23/2017