Desharp 1.3.0

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

Requires NuGet 2.6 or higher.

dotnet add package Desharp --version 1.3.0                
NuGet\Install-Package Desharp -Version 1.3.0                
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="Desharp" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Desharp --version 1.3.0                
#r "nuget: Desharp, 1.3.0"                
#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 Desharp as a Cake Addin
#addin nuget:?package=Desharp&version=1.3.0

// Install Desharp as a Cake Tool
#tool nuget:?package=Desharp&version=1.3.0                

About

C# & VB .NET debugging utility for:

  • dump or log any structuralized variables
  • dump or log exceptions with stack trace and inner exceptions

Dump any variables into:

  • Console window
  • Output debug panel in Visual Studio
  • Web response in floating window
  • Html/text log files on HDD
  • Any WinForms or WPF field component

Instalation

Desharp on Nuget.org

PM> Install-Package Desharp

Demos & Examples


Do Not Miss

  • Visual Studio code snippets
    Download and install predefined VS snippets for most offten Desharp calls.
  • Visual Studio opener
    Automatic Visual Studio (or any other) editor opening on specific file and line from rendered logs and exceptions.

Usage In Code

Dumping & Logging Any Structuralized Variables

C# Basic Example
using Desharp;
using System.Collections.Generic;

var list = new List<int?>() { 100, 200, null };
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 Basic Example
Imports Desharp
Imports System.Collections.Generic

Dim list As New List(Of Int32?)() { 100, 200, null }
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 result for both languages:

[List<Int32?>[3]]
   0: 100 [Int32]
   1: 200 [Int32]
   2: null

Dumping & Logging Exceptions

C# Basic Example
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 Basic Example
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 result for both languages:

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

Dumps & Logs 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

What You Can Dump Or Log

  • any variables
    • primitive variables and it's primitive arrays like: char, int?[] and more
    • collections: Lists, Dictionaries or any collections (IList, IDictionary, ICollection, IEnumerable...)
    • database results: DataSet, DataTable and DataRow with values
    • formated instances: DateTimeOffset, DateTime, TimeSpan, Guid, StringBuilder
    • any custom class instances with rendered events targets, properties values and fields values
    • anonymous objects like: new { any = "value" }
    • Func<> and Delegate types
    • reflection objects are only displayed as type names
  • exceptions
  • exceptions with inner exceptions
  • much more... you can try:-)

What Is Rendered (Dumps & Logs)

  • variables

    • always is rendered/logged the dumped variable:-)
    • dump is rendered with configurable return flag (to return dumped result as string)
    • dump or log is rendered with configurable:
      • source location call (default: false)
      • dump depth (default: 3)
      • maximum string length (default: 1024)
  • exceptions

    • dump or log has always rendered
      • exception message, process and thread id
      • file and line, where exception has been dumped, logged or thrown (only if source code is possible to target by *.PDB file, there is rendered
        a few lines from source code, where the Debug.dump() or Debug.Log() has been called or where Exception has been thrown)
      • exception callstack (with editor opener links in web dump or in html log)
      • all inner exceptions inside the given exception
    • exceptions in web environment has always rendered:
      • requested URL, all http request headers and client IP
      • all loaded assemblies
      • there are different dump rendering for catched and not catched exceptions:
        • if optional flag for catched exception is true, exception is rendered as openable exception in floating bar in left bottom screen corner
        • if optional flag for catched exception is false, exception is rendered over whole browser window immediately with possibility to close it back into floating bar
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  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 (4)

Showing the top 4 NuGet packages that depend on Desharp:

Package Downloads
FalkonryClient

C# ADK for integrating with Falkonry's condition prediction APIs

MvcCore

MvcCore - C# MVC Extensible Framework based on MvcCore PHP library.

DbSharp

C#/VB.NET database utility to comfortly write pure Microsoft SQL/MySQL queries and load them into typed classes and collections.

Desharp.Tests

Desharp - dumping, logging and exceptions rendering tests.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0.3 4,319 9/26/2019
1.3.0.2 656 9/26/2019
1.3.0.1 674 9/26/2019
1.3.0 1,181 9/25/2019
1.2.15 636 9/20/2019
1.2.12 10,495 1/18/2019
1.2.11 8,281 12/11/2017
1.2.9 1,713 11/28/2017
1.2.8 1,349 11/7/2017
1.2.4 4,937 6/14/2017
1.2.3 1,165 6/12/2017
1.1.6 1,087 6/5/2017
1.1.5 1,761 6/4/2017
1.0.1 1,731 3/26/2017
1.0.0 1,104 3/23/2017