提交 7f1f2d2d 编写于 作者: T Tomáš Matoušek

Merge pull request #9193 from tmat/StackFormatterRegression

Fix regression in interactive stack printing
......@@ -820,7 +820,7 @@ private async Task<ScriptState<object>> ExecuteOnUIThread(Script<object> script,
}
catch (Exception e)
{
Console.Error.WriteLine(_replServiceProvider.ObjectFormatter.FormatException(e));
Console.Error.Write(_replServiceProvider.ObjectFormatter.FormatException(e));
return null;
}
}))).ConfigureAwait(false);
......
......@@ -906,6 +906,38 @@ public void StackTrace_GenericMethodInGenericType()
$@"Exception of type 'System.Exception' was thrown.
+ Microsoft.CodeAnalysis.CSharp.Scripting.Hosting.UnitTests.ObjectFormatterTests.Fixture<T>.Method<U>(){string.Format(ScriptingResources.AtFileLine, filePath, 10027)}
+ Microsoft.CodeAnalysis.CSharp.Scripting.Hosting.UnitTests.ObjectFormatterTests.StackTrace_GenericMethodInGenericType(){string.Format(ScriptingResources.AtFileLine, filePath, 10101)}
";
var actual = s_formatter.FormatException(e);
Assert.Equal(expected, actual);
}
}
private static class Fixture2
{
[MethodImpl(MethodImplOptions.NoInlining)]
public static void MethodDynamic()
{
((dynamic)new object()).x();
}
}
[Fact]
public void StackTrace_Dynamic()
{
try
{
Fixture2.MethodDynamic();
Assert.False(true);
}
catch (Exception e)
{
const string filePath = @"z:\Fixture.cs";
var expected =
$@"'object' does not contain a definition for 'x'
+ System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1<T0>(System.Runtime.CompilerServices.CallSite, T0)
+ Microsoft.CodeAnalysis.CSharp.Scripting.Hosting.UnitTests.ObjectFormatterTests.Fixture2.MethodDynamic(){string.Format(ScriptingResources.AtFileLine, filePath, 10123)}
+ Microsoft.CodeAnalysis.CSharp.Scripting.Hosting.UnitTests.ObjectFormatterTests.StackTrace_Dynamic(){string.Format(ScriptingResources.AtFileLine, filePath, 10132)}
";
var actual = s_formatter.FormatException(e);
Assert.Equal(expected, actual);
......
......@@ -26,8 +26,9 @@ public override bool Include(StackFrame frame)
return false;
}
// Type is null for DynamicMethods and global methods.
// TODO (tomat): we don't want to include awaiter helpers, shouldn't they be marked by DebuggerHidden in FX?
if (IsTaskAwaiter(type) || IsTaskAwaiter(type.DeclaringType))
if (type == null || IsTaskAwaiter(type) || IsTaskAwaiter(type.DeclaringType))
{
return false;
}
......@@ -44,8 +45,10 @@ private bool IsHiddenMember(MemberInfo info)
{
while (info != null)
{
// GetCustomAttributes returns null when called on DynamicMethod
// (bug https://github.com/dotnet/corefx/issues/6402)
if (IsGeneratedMemberName(info.Name) ||
info.GetCustomAttributes<DebuggerHiddenAttribute>().Any())
info.GetCustomAttributes<DebuggerHiddenAttribute>()?.Any() == true)
{
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册