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 a LLBLGen 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 the GridDataEditor and hence available in any tools that uses it such as the LLBLGen 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 here CSharpSerializerTests.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<CustomerEntity>
{
new CustomerEntity
  {
    Address = "Obere Str. 57",
    City = "Berlin",

 

which is runnable in LINQPad

Last edited May 29, 2016 at 11:14 AM by JezzaT, version 4

Comments

No comments yet.