Desharp 1.2.15

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.2.15
NuGet\Install-Package Desharp -Version 1.2.15
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.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
#r "nuget: Desharp, 1.2.15"
#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.2.15

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

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)
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 3,924 9/26/2019
1.3.0.2 634 9/26/2019
1.3.0.1 644 9/26/2019
1.3.0 1,099 9/25/2019
1.2.15 561 9/20/2019
1.2.12 10,177 1/18/2019
1.2.11 8,086 12/11/2017
1.2.9 1,669 11/28/2017
1.2.8 1,323 11/7/2017
1.2.4 4,805 6/14/2017
1.2.3 1,122 6/12/2017
1.1.6 1,066 6/5/2017
1.1.5 1,724 6/4/2017
1.0.1 1,676 3/26/2017
1.0.0 1,069 3/23/2017