public static string ForType(TypeReference typedef, string name = null) { if (string.IsNullOrEmpty(name) && !(typedef is GenericInstanceType)) { return typedef.GetReflectionName(); } var sb = new StringBuilder(); if (!string.IsNullOrEmpty(name)) { sb.Append("@").Append(name).Append("/"); } ForType(typedef, sb); return sb.ToString(); }
private static string GetRawGenericName(TypeReference typedef) { var rn = typedef.GetReflectionName(); var index = rn.IndexOf('<'); return index < 0 ? rn : rn.Substring(0, index); }
private static void ForType(TypeReference typedef, StringBuilder sb = null) { if (sb == null) { sb = new StringBuilder(); } if (typedef.HasGenericParameters) { throw new ArgumentException("Open generic types are not supported."); } if (typedef is GenericInstanceType) { var genericType = (GenericInstanceType) typedef; sb.Append(GetRawGenericName(typedef)); sb.Append("<"); for (var i = 0; i < genericType.GenericArguments.Count; ++i) { if (i > 0) { sb.Append(","); } ForType(genericType.GenericArguments[i], sb); } sb.Append(">"); } else { sb.Append(typedef.GetReflectionName()); } }