提交 aff88fad 编写于 作者: C Charles Stoner 提交者: GitHub

Merge pull request #14912 from cston/10861-2

Test Tuples and SymbolDisplay.ToMinimalDisplayParts
......@@ -4675,25 +4675,27 @@ class C
}
[Fact, CompilerTrait(CompilerFeature.Tuples)]
public void TupleFullyQualified()
public void TupleQualifiedNames()
{
var text =
@"using N;
@"using NAB = N.A.B;
namespace N
{
class A
{
internal class B { }
internal class B {}
}
class C<T>
{
// offset 1
}
}
class C
{
#pragma warning disable CS0169
(int One, C<(object[], A.B Two)>, int, object Four, int, object, int, object, A Nine) f;
(int One, N.C<(object[], NAB Two)>, int, object Four, int, object, int, object, N.A Nine) f;
#pragma warning restore CS0169
// offset 2
}";
var format = new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Included,
......@@ -4704,9 +4706,25 @@ class C
var comp = CreateCompilationWithMscorlib(text, references: new[] { ValueTupleRef });
comp.VerifyDiagnostics();
var symbol = comp.GetMember("C.f");
// Fully qualified format.
Verify(
SymbolDisplay.ToDisplayParts(symbol, format),
"(int One, global::N.C<(object[], global::N.A.B Two)>, int, object Four, int, object, int, object, global::N.A Nine) f");
// Minimally qualified format.
Verify(
SymbolDisplay.ToDisplayParts(symbol, SymbolDisplayFormat.MinimallyQualifiedFormat),
"(int One, C<(object[], B Two)>, int, object Four, int, object, int, object, A Nine) C.f");
// ToMinimalDisplayParts.
var model = comp.GetSemanticModel(comp.SyntaxTrees[0]);
Verify(
SymbolDisplay.ToMinimalDisplayParts(symbol, model, text.IndexOf("offset 1"), format),
"(int One, C<(object[], NAB Two)>, int, object Four, int, object, int, object, A Nine) f");
Verify(
SymbolDisplay.ToMinimalDisplayParts(symbol, model, text.IndexOf("offset 2"), format),
"(int One, N.C<(object[], NAB Two)>, int, object Four, int, object, int, object, N.A Nine) f");
}
/// <summary>
......
......@@ -4792,23 +4792,25 @@ End Class
End Sub
<Fact()>
Public Sub TupleFullyQualified()
Dim source =
<compilation>
<file name="a.vb">
Imports N
Public Sub TupleQualifiedNames()
Dim text =
"Imports NAB = N.A.B
Namespace N
Class A
Friend Class B
End Class
End Class
Class C(Of T)
' offset 1
End Class
End Namespace
Class C
Private f As (One As Integer, C(Of (Object(), Two As A.B)), Integer, Four As Object, Integer, Object, Integer, Object, Nine As A)
End Class
</file>
Private f As (One As Integer, N.C(Of (Object(), Two As NAB)), Integer, Four As Object, Integer, Object, Integer, Object, Nine As N.A)
' offset 2
End Class"
Dim source =
<compilation>
<file name="a.vb"><%= text %></file>
</compilation>
Dim format = New SymbolDisplayFormat(
globalNamespaceStyle:=SymbolDisplayGlobalNamespaceStyle.Included,
......@@ -4819,9 +4821,25 @@ End Class
Dim comp = CompilationUtils.CreateCompilationWithMscorlib(source, references:={ValueTupleRef})
comp.VerifyDiagnostics()
Dim symbol = comp.GetMember("C.f")
' Fully qualified format.
Verify(
SymbolDisplay.ToDisplayParts(symbol, format),
"f As (One As Integer, Global.N.C(Of (Object(), Two As Global.N.A.B)), Integer, Four As Object, Integer, Object, Integer, Object, Nine As Global.N.A)")
' Minimally qualified format.
Verify(
SymbolDisplay.ToDisplayParts(symbol, SymbolDisplayFormat.MinimallyQualifiedFormat),
"C.f As (One As Integer, C(Of (Object(), Two As B)), Integer, Four As Object, Integer, Object, Integer, Object, Nine As A)")
' ToMinimalDisplayParts.
Dim model = comp.GetSemanticModel(comp.SyntaxTrees(0))
Verify(
SymbolDisplay.ToMinimalDisplayParts(symbol, model, text.IndexOf("offset 1"), format),
"f As (One As Integer, C(Of (Object(), Two As NAB)), Integer, Four As Object, Integer, Object, Integer, Object, Nine As A)")
Verify(
SymbolDisplay.ToMinimalDisplayParts(symbol, model, text.IndexOf("offset 2"), format),
"f As (One As Integer, N.C(Of (Object(), Two As NAB)), Integer, Four As Object, Integer, Object, Integer, Object, Nine As N.A)")
End Sub
' A tuple type symbol that is not Microsoft.CodeAnalysis.VisualBasic.Symbols.TupleTypeSymbol.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册