title: How do I change a field type using FieldTypeDeclaration ( Roslyn )
body: <p>I am using the visual studio project type - Stand-Alone Code Analysis Tool. I am using the following code but the ToString() is showing an unexpected result.</p>
  
  <pre><code>static void Main(string[] args)
  {
      var classDoc = @"public class SomeClass{
              private SomeOtherClass someOtherClass;
          }";
  
      SyntaxTree classTree=SyntaxFactory.ParseSyntaxTree(classDoc);
      var classDecl = (ClassDeclarationSyntax)classTree.GetRoot().DescendantNodes()
          .First(d =&gt; d is ClassDeclarationSyntax);
  
      var field = classDecl.Members.OfType&lt;FieldDeclarationSyntax&gt;().First();
      var fieldType = field.Declaration.Type;
      var newFieldType = SyntaxFactory.ParseName("System.Windows.Forms.UserControl");
      var newField=field.ReplaceNode(fieldType, newFieldType);
      var newFieldStr = newField.ToString();
  }
  </code></pre>
  
  <p>The value of <code>newFieldStr</code> is</p>
  
  <pre><code>private System.Windows.Forms.UserControlsomeOtherClass;
  </code></pre>
  
  <p>Please advise how I can get the expected result.</p>