[mono-api-html] Print string fields with no (or null) value without an NRE.
[mono.git] / mcs / mcs / support.cs
index d4e018c32594ad118a57c80cd32f675943c470d3..be2f6a48583cfee7c23627d640ad7d46d0f22024 100644 (file)
@@ -36,7 +36,7 @@ namespace Mono.CSharp {
                        return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode (obj);
                }
        }
-#if !NET_4_0 && !MONODROID
+#if !NET_4_0 && !MOBILE_DYNAMIC
        public class Tuple<T1, T2> : IEquatable<Tuple<T1, T2>>
        {
                public Tuple (T1 item1, T2 item2)
@@ -322,4 +322,38 @@ namespace Mono.CSharp {
                        }
                }
        }
+
+       struct TypeNameParser
+       {
+               internal static string Escape(string name)
+               {
+                       if (name == null) {
+                               return null;
+                       }
+                       StringBuilder sb = null;
+                       for (int pos = 0; pos < name.Length; pos++) {
+                               char c = name[pos];
+                               switch (c) {
+                                       case '\\':
+                                       case '+':
+                                       case ',':
+                                       case '[':
+                                       case ']':
+                                       case '*':
+                                       case '&':
+                                               if (sb == null) {
+                                                       sb = new StringBuilder(name, 0, pos, name.Length + 3);
+                                               }
+                                               sb.Append("\\").Append(c);
+                                               break;
+                                       default:
+                                               if (sb != null) {
+                                                       sb.Append(c);
+                                               }
+                                               break;
+                               }
+                       }
+                       return sb != null ? sb.ToString() : name;
+               }
+       }
 }