public static string ToCompilableString(this Type type) { var str = string.Empty; if (SerializationTools.TryGetBuiltInTypeToString(type, out str)) { return(str); } else if (type.IsGenericType) { return(type.FullName.Split('`')[0] + "<" + string.Join(", ", type.GetGenericArguments().Select(argType => argType.ToCompilableString()).ToArray()) + ">"); } else if (type.IsArray) { return(type.GetElementType().ToCompilableString() + "[" + new string(',', type.GetArrayRank() - 1) + "]"); } return(type.IsNested ? type.FullName.Replace('+', '.') : type.FullName); }