private static async Task Exceptions( StreamWriter writer, Assembly assembly, MethodInfo method, XDocument xmlComments) { var exceptions = XmlCommentHelper.MethodElement(xmlComments, method)?.Descendants("exception").ToList(); if (exceptions != null && exceptions.Count > 0) { await writer.WriteLineAsync("### Exceptions"); foreach (var exception in exceptions) { var exceptionTypeName = exception.Attributes("cref").FirstOrDefault()?.Value; if (exceptionTypeName != null) { var exceptionType = TypeHelper.GetType( assembly, exceptionTypeName.Substring(exceptionTypeName.IndexOf(':', StringComparison.Ordinal) + 1)); if (exceptionType != null) { await TypeHelper.FullName(writer, exceptionType, t => t.Name, "<", ">"); } else { var start = exceptionTypeName.LastIndexOf('.'); if (start >= 0) { exceptionTypeName = exceptionTypeName.Substring(start + 1); } var end = exceptionTypeName.IndexOf('`', StringComparison.Ordinal); if (end >= 0) { exceptionTypeName = exceptionTypeName.Substring(0, end); } await writer.WriteAsync(exceptionTypeName); } await writer.WriteLineAsync(" "); await XmlCommentHelper.WriteValue(writer, exception); await writer.WriteLineAsync(); await writer.WriteLineAsync(); } } } }