Skip to content

ObjectAsSourceCodeDebuggerVisualizer

Jeremy Thomas edited this page Dec 11, 2017 · 2 revisions

The Object-as-Source-Code Debugger Visualizer is a Debugger Visualizer that displays C# source code that will generate the .Net object chosen in the debugger. In other words: It will serialize the object as C# source text. Its main purpose is to generate an object graph for input into a unit test. The specific use case it was made for is testing code that processed the results of aLLBLGen Pro LINQ query. It is essentially a Debugger Visualizer wrapper around a modified version of https://github.com/jefflomax/csharp-object-to-object-literal

Installation

Download x or y, you will be presented with this install screen:

image

You may need to run it as admin to install for all users. As well as this Debugger Visualizer for Visual Studio the source code generation functionality is exposed in theGridDataEditor and hence available in any tools that uses it such as theLLBLGen Pro LINQPad Driver and LLBLGen Entity Browser

Similar Tools

At the time I wrote this tool, late 2014, none of these other tools did quite what I needed.

Using the Source Code Generation API

The class is here CSharpSerializer.cs, the method to call is CSharpSerializer.SerializeToCSharp, unit tests are hereCSharpSerializerTests.cs

Example calling from LINQPad using the LLBLGen Pro LINQPad Driver against the Northwind DB.

Customer.PrefetchOrders().ToEntityCollection2().SerializeToCSharp(OutputFormat.LinqpadProgram,"Fields,EntityFactoryToUse,Picture")

which creates code like this:

// Object Literal // Globally Excluded Properties: //  Fields,EntityFactoryToUse,Picture void Main() {   ResultContainer.Result().Dump(); } public static class ResultContainer { public  static object Result() { var entityCollection9082615 = new EntityCollection { new CustomerEntity   {     Address = "Obere Str. 57",     City = "Berlin",

which is runnable in LINQPad

Clone this wiki locally