Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio Debugger Copy object

I am wondering if anything like this exists:

When debugging in visual studio it would be really good if it had the ability to copy an object(all its properties and values) into memory. I am thinking of something that you could put a break point in code -> right click the object -> Click "create moq into clipboard"

Then you could go to your unit test, paste the text which would paste the code to create that object with all of those properties.

I imagine this would save loads of time, and would be really useful for fixing bugs.

One of the difficult things I find with unit test is the manual process in creating the mock objects.

like image 969
user1619480 Avatar asked Mar 27 '14 14:03

user1619480


People also ask

How do you copy an object in Visual Studio?

In Visual Studio debug mode it's possible to hover over variables to show their value and then right-click to "Copy", "Copy Expression" or "Copy Value". In case the variable is an object and not just a basic type, there's a + sign to expand and explore the object.

What is difference between F10 and F11 in Visual Studio?

In short, pressing F11 will take you to every line including your function body, but F10 allows to move from one line to the the immediate next line.


1 Answers

I'm a bit late to the party but I created a Visual Studio extension that does something very similar to what you're looking for. It will generate C# code to initialize an object from your visual studio debugging windows.

Here's the extension: Visual Studio Marketplace > Object Explorer

And here's an accompanying blog post: Exporting Objects from the Visual Studio Debugger

like image 87
Omar Elabd Avatar answered Oct 21 '22 01:10

Omar Elabd