Desharp 1.3.0.3

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)

Requires NuGet 2.6 or higher.

Install-Package Desharp -Version 1.3.0.3
dotnet add package Desharp --version 1.3.0.3
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 = &quot;value&quot; }
    • Func&lt;&gt; 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);

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 = &quot;value&quot; }
    • Func&lt;&gt; 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);

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