Monday, December 7, 2015

Exporting Objects from the Visual Studio Debugger


I had been searching for a way to export objects from my debugging windows (ex. locals, autos, watch) to their C# object initialization code for creating unit tests. There have been a few cases where there are some complex objects that I load through a database which would make great unit tests. Unfortunately i was not able to find anything like that, so I decided to create it myself. Enter Object Exporter.


Object Exporter is accessed through the tools menu and is only visible when you are debugging.
Export Objects (Tool Menu)
Once selected a dialog is shown with settings for the Object Export.
Export Objects (Select Objects)
The Output Format details which format you want your exported objects to be in. Maximum Object Depth refers to the maximum depth the Serializer will generate text for, this is important as some objects can have an infinite depth. Once you select a debugging window from the drop down, it’s objects will be loaded onto the screen and you may check the objects you wish to export.
The objects which can be selected correspond to the objects that exist within the various windows:
Export Objects (Locals)
Once the objects are selected and the “Export” button is selected, another dialog with the generated texts appear:
Xml:
Export Objects (Xml Generated)
Json:
Export Objects (Json Generated)
CSharp:
Export Objects (CSharp Generated)
You can copy the text in the currently selected tab by selecting “Copy To Clipboard” or you can save all the objects to a folder by selecting the “Save All to Folder” button, a file per tab will be generated.
That’s pretty much it.
Enjoy

By Unknown with No comments

0 коммент.:

Post a Comment