Desharp 1.3.0.3

Requires NuGet 2.6 or higher.

dotnet add package Desharp --version 1.3.0.3                
NuGet\Install-Package Desharp -Version 1.3.0.3                
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.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Desharp --version 1.3.0.3                
#r "nuget: Desharp, 1.3.0.3"                
#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.3

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

Desharp - C# & VB .NET Debugging Tool


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:-)

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.

Basic Dumping & Logging Any Structuralized Variables

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

Dumped result for both languages:

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

Basic Dumping & Logging Exceptions

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
}

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

All Dump Methods

Dump any values to application output (in web applications into debug bar,
in desktop applications into console or debug output window)

Desharp.Debug.Dump(params object[] args);

Dump exception instance to application output if output dumping is enabled. It renders:

  • exception type, exception message and exception hash id
  • yes/no if exception has been caught or not caught
  • error file where exception has been thrown
  • thread call stack All inner exceptions after this exception in the same way.
Desharp.Debug.Dump(Exception exception = null, DumpOptions? options = default(DumpOptions?));

Dump any values to application output (in web applications into debug bar,
in desktop applications into console or debug output window)
This method dumps only single object with dump options like to dump
different object depth as usual, different string length or to dump source location and more...

Desharp.Debug.Dump(object obj, DumpOptions? options = default(DumpOptions?));

Dump any type value to direct application output (not into web request debug
bar in web applications!) and stop request/thread (in web applications dump into
direct response body, in desktop applications into console or debug output window).

Desharp.Debug.DumpAndDie(object obj = null, DumpOptions? options = default(DumpOptions?));

All Log Methods

Log exception instance as dumped string into exceptions.log|exceptions.html file. It stores:

  • exception type
  • exception message
  • if exception has been caught or not caught
  • exception hash id
  • error file where exception has been thrown
  • thread call stack All inner exceptions after this exception in the same way.
Desharp.Debug.Log(Exception exception = null);

Log any type value to application .log|.html file, specified by level param.

Desharp.Debug.Log(object obj = null, Level level = Level.INFO, int maxDepth = 0, int maxLength = 0);

All Other Methods

Print to application output or log into file (if enabled) first param to be true
or not and describe what was equal or not in first param by second param message.

Desharp.Debug.Assert(bool assertion, string description = "", Level logLevel = Level.DEBUG);

Configure Desharp assembly from running application environment and override
any XML config settings or automatically detected settings.

Desharp.Debug.Configure(DebugConfig cfg);

Enable or disable variables dumping from application code environment for all threads
or get enabled/disabled Desharp dumping state if no boolean param provided.

Desharp.Debug.Enabled(bool? enabled = default(bool?));

Return last uncaught Exception in request, mostly used in web applications by
error page rendering process to know something about Exception before.

Desharp.Debug.GetLastError();

Return spent request processing time for web applications or return application
up time for all other platforms.

Desharp.Debug.GetProcessingTime();

Print current thread stack trace into application output and exit running application. In web applications - stop current request, in any other applications - stop application with all it's threads and exit.

Desharp.Debug.Stop();

Prints to output or into log file number of seconds from last timer call under called name in seconds with 3 floating point decimal spaces. If no name specified or name is empty string, there is returned: Web applications - number of seconds from request beginning. Desktop applications - number of seconds from application start.

Desharp.Debug.Timer(string name = null, bool returnTimerSeconds = false, Level logLevel = Level.DEBUG);
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,333 9/26/2019
1.3.0.2 657 9/26/2019
1.3.0.1 675 9/26/2019
1.3.0 1,184 9/25/2019
1.2.15 637 9/20/2019
1.2.12 10,496 1/18/2019
1.2.11 8,293 12/11/2017
1.2.9 1,714 11/28/2017
1.2.8 1,350 11/7/2017
1.2.4 4,940 6/14/2017
1.2.3 1,166 6/12/2017
1.1.6 1,088 6/5/2017
1.1.5 1,764 6/4/2017
1.0.1 1,732 3/26/2017
1.0.0 1,107 3/23/2017