title: Roslyn Analyzer Check if Property Declaration is a Standard Type (int, string, Guid, etc)
body: <p>I am using Roslyn Analyzer to analyze code and I want to check if a Property Declaration is a Standard Type (for example, string, int, Guid, DateTime, etc).</p>
  
  <p>For example I want to analyze the below Code:</p>
  
  <pre><code>namespace myApp.Models
  {
      public class MyModel
      {
          public int Id { get; set; }
          public DateTime StartDate { get; set; }
          public MyOtherModel MyOtherModel { get; set; }
      }
  
      public class MyOtherModel
      {
          public int Id { get; set; }
          public string Name { get; set; }
      }
  }
  </code></pre>
  
  <p>I can get all property declarations by using:</p>
  
  <pre><code>var node = CSharpSyntaxTree.ParseText(aboveCodeAsString).GetRoot();
  IEnumerable&lt;ClassDeclarationSyntax&gt; classDeclarationSyntaxes = node.DescendantNodes().OfType&lt;ClassDeclarationSyntax&gt;().FirstOrDefault();
  var propertyDeclarations = classDeclarationSyntax.DescendantNodes().OfType&lt;Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax&gt;();
  foreach (var propertyDeclaration in propertyDeclarations)
  {
      ...
  }
  </code></pre>
  
  <p>What I need is function IsStandardType(PropertyDeclarationSyntax propertyDeclarationSyntax) that returns true for:</p>
  
  <pre><code>public int myInt { get; set; }
  public DateTime dateTime { get; set; }
  </code></pre>
  
  <p>But false for:</p>
  
  <pre><code>public MyOtherClass myOtherModel { get; set; }
  </code></pre>
  
  <p>In this case all models will be in the same namespace so a possible solution is to compare the namespace of all property declarations to the namespace of the model. If they are not equal, then I know it is a Standard Type.</p>
  
  <p>But, I am also having trouble getting the namespace of a property declaration (for example System.DateTime in case of "public DateTime dateTime { get; set; }" so I need help with that too.</p>
  
  <p>All models are however in different files so this might not be the best solution.</p>