internal static string GetFriendlyName(this Type type, TranslationSettings translationSettings) { var buffer = new TranslationBuffer((type.FullName ?? type.ToString()).Length); buffer.WriteFriendlyName(type, translationSettings); return(buffer.GetContent()); }
/// <summary> /// Translates the given <paramref name="method"/> into a readable string. /// </summary> /// <param name="method">The MethodInfo to translate.</param> /// <returns>A readable string version of the given <paramref name="method"/>.</returns> public static string Translate(MethodInfo method) { if (method == null) { return("[Method not found]"); } var buffer = new TranslationBuffer(method.ToString().Length); WriteModifiersToTranslation(method, buffer); var isProperty = method.IsPropertyGetterOrSetterCall(out var property); buffer.WriteFriendlyName(isProperty ? property.PropertyType : method.ReturnType); buffer.WriteSpaceToTranslation(); if (method.DeclaringType != null) { buffer.WriteFriendlyName(method.DeclaringType); buffer.WriteToTranslation('.'); } if (isProperty) { buffer.WriteToTranslation(property.Name); buffer.WriteToTranslation((method.ReturnType != typeof(void)) ? " { get; }" : " { set; }"); return(buffer.GetContent()); } buffer.WriteToTranslation(method.Name); if (method.IsGenericMethod) { WriteGenericArgumentsToTranslation(method.GetGenericArguments(), buffer); } WriteParametersToTranslation(method, buffer); return(buffer.GetContent()); }
internal static string GetFriendlyName(this Type type, TranslationSettings translationSettings) { if (type.FullName == null) { // An open generic parameter Type: return(null); } var buffer = new TranslationBuffer(type.FullName.Length); buffer.WriteFriendlyName(type, translationSettings); return(buffer.GetContent()); }
/// <summary> /// Translates the given <paramref name="type"/> into a readable string. /// </summary> /// <param name="type">The Type to translate.</param> /// <returns>A readable string version of the given <paramref name="type"/>.</returns> public static string Translate(Type type) { if (type == null) { return("[Type not found]"); } var buffer = new TranslationBuffer(type.ToString().Length); WriteModifiersToTranslation(type, buffer); buffer.WriteFriendlyName(type); return(buffer.GetContent()); }
/// <summary> /// Translates the given <paramref name="ctor"/> into a readable string. /// </summary> /// <param name="ctor">The ConstructorInfo to translate.</param> /// <returns>A readable string version of the given <paramref name="ctor"/>.</returns> public static string Translate(ConstructorInfo ctor) { if (ctor == null) { return("[Constructor not found]"); } var buffer = new TranslationBuffer(ctor.ToString().Length); WriteAccessibilityToTranslation(ctor, buffer); buffer.WriteFriendlyName(ctor.DeclaringType); WriteParametersToTranslation(ctor, buffer); return(buffer.GetContent()); }