<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\SuppressMessageAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\ConditionalAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Debug.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\StackTraceHiddenAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\DivideByZeroException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\DllNotFoundException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Double.cs" />
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Diagnostics
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)]
+ internal sealed class StackTraceHiddenAttribute : Attribute
+ {
+ public StackTraceHiddenAttribute() { }
+ }
+}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
public bool IsCompleted => _value.IsCompleted;
/// <summary>Gets the result of the ValueTask.</summary>
+ [StackTraceHidden]
public TResult GetResult() =>
_value._task == null ?
_value._result :
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
public bool IsCompleted => _value.IsCompleted;
/// <summary>Gets the result of the ValueTask.</summary>
+ [StackTraceHidden]
public TResult GetResult() =>
_value._task == null ?
_value._result :
{
StackFrame sf = GetFrame(iFrameIndex);
MethodBase mb = sf.GetMethod();
- if (mb != null)
+ if (mb != null && (ShowInStackTrace(mb) ||
+ (iFrameIndex == m_iNumOfFrames - 1))) // Don't filter last frame
{
// We want a newline at the end of every line except for the last
if (fFirstFrame)
return sb.ToString();
}
+ private static bool ShowInStackTrace(MethodBase mb)
+ {
+ Debug.Assert(mb != null);
+ return !(mb.IsDefined(typeof(StackTraceHiddenAttribute)) || (mb.DeclaringType?.IsDefined(typeof(StackTraceHiddenAttribute)) ?? false));
+ }
+
// This helper is called from within the EE to construct a string representation
// of the current stack trace.
private static String GetManagedStackTraceStringHelper(bool fNeedFileInfo)
/// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
/// <exception cref="System.Threading.Tasks.TaskCanceledException">The task was canceled.</exception>
/// <exception cref="System.Exception">The task completed in a Faulted state.</exception>
+ [StackTraceHidden]
public void GetResult()
{
ValidateEnd(m_task);
/// prior to completing the await.
/// </summary>
/// <param name="task">The awaited task.</param>
+ [StackTraceHidden]
internal static void ValidateEnd(Task task)
{
// Fast checks that can be inlined.
/// the await on the task, and throws an exception if the task did not complete successfully.
/// </summary>
/// <param name="task">The awaited task.</param>
+ [StackTraceHidden]
private static void HandleNonSuccessAndDebuggerNotification(Task task)
{
// NOTE: The JIT refuses to inline ValidateEnd when it contains the contents
}
/// <summary>Throws an exception to handle a task that completed in a state other than RanToCompletion.</summary>
+ [StackTraceHidden]
private static void ThrowForNonSuccess(Task task)
{
Debug.Assert(task.IsCompleted, "Task must have been completed by now.");
/// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
/// <exception cref="System.Threading.Tasks.TaskCanceledException">The task was canceled.</exception>
/// <exception cref="System.Exception">The task completed in a Faulted state.</exception>
+ [StackTraceHidden]
public TResult GetResult()
{
TaskAwaiter.ValidateEnd(m_task);
/// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
/// <exception cref="System.Threading.Tasks.TaskCanceledException">The task was canceled.</exception>
/// <exception cref="System.Exception">The task completed in a Faulted state.</exception>
+ [StackTraceHidden]
public void GetResult()
{
TaskAwaiter.ValidateEnd(m_task);
/// <exception cref="System.NullReferenceException">The awaiter was not properly initialized.</exception>
/// <exception cref="System.Threading.Tasks.TaskCanceledException">The task was canceled.</exception>
/// <exception cref="System.Exception">The task completed in a Faulted state.</exception>
+ [StackTraceHidden]
public TResult GetResult()
{
TaskAwaiter.ValidateEnd(m_task);
=============================================================================*/
using System;
+using System.Diagnostics;
namespace System.Runtime.ExceptionServices
{
// This method will restore the original stack trace and bucketing details before throwing
// the exception so that it is easy, from debugging standpoint, to understand what really went wrong on
// the original thread.
+ [StackTraceHidden]
public void Throw()
{
// Restore the exception dispatch details before throwing the exception.
namespace System
{
+ [StackTraceHidden]
internal static class ThrowHelper
{
internal static void ThrowArrayTypeMismatchException()