提交 1f95a043 编写于 作者: B Brett V. Forsgren

don't sort exception types before display

上级 0b9617f0
......@@ -4152,7 +4152,8 @@ class TestClass
/// <exception cref=""T:MyNs.MyException2""></exception>
/// <exception cref=""System.Int32""></exception>
/// <exception cref=""double""></exception>
/// <exception cref=""Not_A_Class_And_Therefore_Not_Listed""></exception>
/// <exception cref=""Not_A_Class_But_Still_Displayed""></exception>
/// <exception cref=""T:"">looks like a proper prefix but isn't</exception>
void M()
{
M$$();
......@@ -4160,7 +4161,7 @@ void M()
}
}
",
Exceptions($"\r\n{WorkspacesResources.Exceptions}\r\n MyException1\r\n MyException2\r\n double\r\n int"));
Exceptions($"\r\n{WorkspacesResources.Exceptions}\r\n MyException1\r\n MyException2\r\n int\r\n double\r\n Not_A_Class_But_Still_Displayed\r\n T:"));
}
}
}
......@@ -2049,14 +2049,15 @@ Namespace MyNs
''' <exception cref=""T:MyNs.MyException2""></exception>
''' <exception cref=""System.Int32""></exception>
''' <exception cref=""Double""></exception>
''' <exception cref=""Not_A_Class_And_Therefore_Not_Listed""></exception>
''' <exception cref=""Not_A_Class_But_Still_Displayed""></exception>
''' <exception cref=""T:"">looks like a proper prefix but isn't</exception>
Sub M()
M$$()
End Sub
End Class
End Namespace
",
Exceptions($"{vbCrLf}{WorkspacesResources.Exceptions}{vbCrLf} MyException1{vbCrLf} MyException2{vbCrLf} Double{vbCrLf} Integer"))
Exceptions($"{vbCrLf}{WorkspacesResources.Exceptions}{vbCrLf} MyException1{vbCrLf} MyException2{vbCrLf} Integer{vbCrLf} Double{vbCrLf} Not_A_Class_But_Still_Displayed{vbCrLf} T:"))
End Sub
End Class
......
......@@ -156,24 +156,32 @@ private async Task AddPartsAsync(ImmutableArray<ISymbol> symbols)
private void AddExceptions(ISymbol symbol)
{
// clean up the list of possible exceptions by de-duplicating and ordering them
var exceptions =
symbol.GetDocumentationComment().ExceptionTypes
.Distinct()
.OrderBy(e => e)
.Select(e => DocumentationCommentId.GetFirstSymbolForDeclarationId(e, _semanticModel.Compilation))
.WhereNotNull()
.ToList();
if (exceptions.Any())
var exceptionTypes = symbol.GetDocumentationComment().ExceptionTypes;
if (exceptionTypes.Any())
{
var parts = new List<SymbolDisplayPart>();
parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Text, null, $"\r\n{WorkspacesResources.Exceptions}"));
foreach (var exception in exceptions)
parts.Add(new SymbolDisplayPart(kind: SymbolDisplayPartKind.Text, symbol: null, text: $"\r\n{WorkspacesResources.Exceptions}"));
foreach (var exceptionString in exceptionTypes)
{
parts.AddRange(LineBreak());
parts.AddRange(Space(count: 2));
parts.AddRange(_displayService.ToMinimalDisplayParts(_semanticModel, _position, exception));
// try to get the actual exception symbol
var exceptionSymbol = DocumentationCommentId.GetFirstSymbolForDeclarationId(exceptionString, _semanticModel.Compilation);
if (exceptionSymbol != null)
{
parts.AddRange(_displayService.ToMinimalDisplayParts(_semanticModel, _position, exceptionSymbol));
}
else
{
// unable to parse exception symbol, fall back to displaying the raw text after trying to
// strip off the leading prefix of "[E|F|M|N|P|T|!]:"
var colonIndex = exceptionString.IndexOf(':');
var displayText = colonIndex >= 0 && exceptionString.Length > colonIndex + 1
? exceptionString.Substring(colonIndex + 1)
: exceptionString;
parts.Add(new SymbolDisplayPart(kind: SymbolDisplayPartKind.Text, symbol: null, text: displayText));
}
}
AddToGroup(SymbolDescriptionGroups.Exceptions, parts);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册