private OS.TypeSpec TranslateTypeSpec(RS.TypeSpec t)
 {
     if (t.OnTypeRef)
     {
         if (t.TypeRef.Value.Equals("Binary", StringComparison.OrdinalIgnoreCase))
         {
             ByteUsed = true;
             ListUsed = true;
             TypeUsed = true;
             var tBinary = OS.TypeSpec.CreateTypeRef(new OS.TypeRef {
                 Name = new List <String> {
                     "List"
                 }, Version = ""
             });
             var tByte = OS.TypeSpec.CreateTypeRef(new OS.TypeRef {
                 Name = new List <String> {
                     "Byte"
                 }, Version = ""
             });
             return(OS.TypeSpec.CreateGenericTypeSpec(new OS.GenericTypeSpec {
                 TypeSpec = tBinary, ParameterValues = new List <OS.TypeSpec> {
                     tByte
                 }
             }));
         }
         else if (PrimitiveNames.Contains(t.TypeRef.Value))
         {
             return(OS.TypeSpec.CreateTypeRef(new OS.TypeRef {
                 Name = new List <String> {
                     t.TypeRef.Value
                 }, Version = ""
             }));
         }
         else
         {
             return(OS.TypeSpec.CreateTypeRef(new OS.TypeRef {
                 Name = NamespaceParts.Concat(new List <String> {
                     t.TypeRef.Value
                 }).ToList(), Version = ""
             }));
         }
     }
     else if (t.OnOptional)
     {
         UnitUsed     = true;
         TypeUsed     = true;
         OptionalUsed = true;
         var Underlying = TranslateTypeSpec(RS.TypeSpec.CreateTypeRef(t.Optional));
         return(OS.TypeSpec.CreateGenericTypeSpec(new OS.GenericTypeSpec {
             TypeSpec = OS.TypeSpec.CreateTypeRef(new OS.TypeRef {
                 Name = new List <String> {
                     "Optional"
                 }, Version = ""
             }), ParameterValues = new List <OS.TypeSpec> {
                 Underlying
             }
         }));
     }
     else
     {
         throw new InvalidOperationException();
     }
 }