Robbie
Robbie

Reputation: 458

In Visual Studio, is there a way to automatically convert an objects data to object creation code?

In Visual Studio or in a VS plugin, is there a way to automatically convert an objects data at run time to generated class initialization code? I am trying to create test data and It would be really convenient to have the ability to copy a run time objects data into object initialization code through intellisense.

If this isn't possible or has yet to be created, are there alternatives to accomplish something similar?

Upvotes: 0

Views: 168

Answers (3)

Sergey Vlasov
Sergey Vlasov

Reputation: 27930

Object Exporter extension lets you export out an object while debugging in Visual Studio to C# Object Initialization Code, JSON and XML.

Upvotes: 1

Falco
Falco

Reputation: 3436

I don't think there is a build-in function for this, but you can easily write one yourself if you're talking about C# with Reflections.

With C/C++ shouldn't the hexdump of the object be enough, if you just write the raw data at the position of the pointer?

Upvotes: 0

SomeWittyUsername
SomeWittyUsername

Reputation: 18368

Assuming you're talking about C++ - this is called copy constructor and it's part of the language definition.

Upvotes: 0

Related Questions