title: Get Type of 'var' with Roslyn?
body: <p>I've got a .cs file named 'test.cs' which essentially looks like:</p>
  
  <pre><code>namespace test
  {
      public class TestClass
      {
          public void Hello()
          {
              var x = 1;
          }
      }
  }
  </code></pre>
  
  <p>I'm trying to parse this with Roslyn and get the type of x, which should be 'int', but I can only find out that it's type 'var', I can't seem to get the actual underlying type.</p>
  
  <p>Here's basically what my code is now</p>
  
  <pre><code>var location = "test.cs";
  var sourceTree = CSharpSyntaxTree.ParseFile(location);
  
  var root = (CompilationUnitSyntax)sourceTree.GetRoot();
  foreach (var member in root.Members)
  {
      //...get to a method
      var method = (MethodDeclarationSyntax())member;
      foreach (var child in method.Body.ChildNodes())
      {
          if (child is LocalDeclarationStatementSyntax)
          {
              //var x = 1;
              child.Type.RealType()?
          }
      }
  }
  </code></pre>
  
  <p>How can I get the real type of child? I've seen some things saying I should use a SemanticModel or Solution or a Workspace, but I can't seem to find out how load my test solution with Roslyn and then get the type of 'x'.</p>
  
  <p>Also, I haven't been able to find any really good Roslyn documentation, it all seems to be spread out among a bunch of different versions and nothing for beginners like me. Does anyone know of an 'intro to Roslyn' or similar quickstart I could read up on?</p>