title: How to parse C# generic type names?
body: <p>How can I parse C#-style generic type names of the format <code>List&lt;int&gt;</code> or <code>Dictionary&lt;string,int&gt;</code> or even more complex <code>Dictionary&lt;string,Dictionary&lt;System.String,int[]&gt;&gt;</code>.  Assume that these names are strings and may not actually represent existing types.  It should just as easily be be able to parse <code>BogusClass&lt;A,B,Vector&lt;C&gt;&gt;</code>.  To be clear, I am NOT interested in parsing .NET internal type names of the format <code>List`1[[System.Int32]]</code>, but actual C# type names as they would appear in the source code, with or without namespace qualifiers using dot notation.</p>
  
  <p>Regular expressions are out because these are nested structures.  I thought perhaps the System.CodeDom.CodeTypeReference constructor would parse it for me since it has <code>string BaseType</code> and <code>CodeTypeReferenceCollection TypeArguments</code> members, but those apparently need to be set manually.</p>
  
  <p>CodeTypeReference is the kind of structure I need:</p>
  
  <pre><code>class TypeNameStructure
  {
      public string Name;
      public TypeNameStructure[] GenericTypeArguments;
      public bool IsGenericType{get;}
      public bool IsArray{get;} //would be nice to detect this as well
  
      public TypeNameStructure( string friendlyCSharpName )
      {
         //Parse friendlyCSharpName into name and generic type arguments recursively
      }
  }
  </code></pre>
  
  <p>Are there any existing classes in the framework to achieve this kind of type name parsing?  If not, how would I go about parsing this?</p>