title: Is there a serializer for .net which will output c# code?
body: <p>I'm looking for a serializer which could take an instance, and serialize it to a string which would contain c# code, representing the contents of the graph.
  The class would function similar to <code>SerializeObject</code> in JSON.NET.</p>
  
  <p>I know only a very narrow set of structures will work, but the ones I'm interested in are quite simple and they would. </p>
  
  <p>Bonus points if anyone knows of a Visual Studio Visualizer with similar functionality.</p>
  
  <p><strong>Edit:</strong>
  The output will be used in a different application at compile time. I don't need to deserialize the output(c# code) at runtime, it gets saved to a file for analysis.</p>
  
  <pre><code>var foo = new Foo() { Number = 1, Bar = new Bar() { Str = "Bar"}};
  string sourceCode = Magic.SerializeObject(foo);
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Foo obj = new Foo();
  obj.Number = 1;
  obj.RefType = null; // infer this
  obj.Bar = new Bar();
  obj.Bar.Str = "Bar";
  </code></pre>