未验证 提交 925d215b 编写于 作者: M mizuniga 提交者: GitHub

Removed the hard brackets surrounding tuples in the debugger display … (#43389)

上级 da62ba87
......@@ -235,7 +235,7 @@ public void Tuples()
AssertEx.AssertEqualToleratingWhitespaceDifferences(
$@"{LogoAndHelpPrompt}
> (1,2)
[(1, 2)]
(1, 2)
> ", runner.Console.Out.ToString());
}
......
......@@ -67,6 +67,20 @@ public void Objects()
Assert.Equal(@"Sort { aB=-1, ab=1, Ac=-1, Ad=1, ad=-1, aE=1, aF=-1, AG=1 }", str);
}
[Fact]
public void TupleType()
{
var tup = new Tuple<int, int>(1, 2);
Assert.Equal("(1, 2)", s_formatter.FormatObject(tup));
}
[Fact]
public void ValueTupleType()
{
(int, int) tup = (1, 2);
Assert.Equal("(1, 2)", s_formatter.FormatObject(tup));
}
[Fact]
public void ArrayMethodParameters()
{
......
......@@ -9,6 +9,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using Microsoft.Cci;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Scripting.Hosting
......@@ -708,14 +709,48 @@ private void FormatMultidimensionalArrayElements(Builder result, Array array, bo
#region Scalars
private bool IsTuple(object obj)
{
#if NETSTANDARD2_0
if (obj is null)
{
return false;
}
var type = obj.GetType();
if (!type.IsGenericType)
{
return false;
}
int backtick = type.FullName.IndexOf('`');
if (backtick < 0)
{
return false;
}
var nonGenericName = type.FullName[0..backtick];
return nonGenericName == "System.ValueTuple" || nonGenericName == "System.Tuple";
#else
return obj is ITuple;
#endif
}
private void ObjectToString(Builder result, object obj)
{
try
{
string str = obj.ToString();
result.Append('[');
result.Append(str);
result.Append(']');
if (IsTuple(obj))
{
result.Append(str);
}
else
{
result.Append('[');
result.Append(str);
result.Append(']');
}
}
catch (Exception e)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册