in src/Microsoft.Azure.WebJobs.Host/Diagnostics/ExceptionFormatter.cs [116:178]
private static bool ShouldShowFrame(Type declaringType) =>
!(declaringType != null && typeof(INotifyCompletion).IsAssignableFrom(declaringType));
private static void FormatFrame(StringBuilder stringBuilder, StackFrame frame)
{
var method = frame.GetMethod();
var declaringType = method?.DeclaringType;
if (!ShouldShowFrame(declaringType))
{
return;
}
stringBuilder.AppendLine();
stringBuilder.Append(" at ");
bool isAsync;
FormatMethodName(stringBuilder, declaringType, out isAsync);
if (!isAsync)
{
stringBuilder.Append(method?.Name);
var methodInfo = method as MethodInfo;
if (methodInfo?.IsGenericMethod == true)
{
FormatGenericArguments(stringBuilder, methodInfo.GetGenericArguments());
}
}
else if (declaringType?.IsGenericType == true)
{
FormatGenericArguments(stringBuilder, declaringType.GetGenericArguments());
}
stringBuilder.Append("(");
if (isAsync)
{
// Best effort
string methodFromType = GetMethodFromAsyncStateMachineType(declaringType);
List<MethodInfo> methods = null;
if (methodFromType != null)
{
methods = declaringType?.DeclaringType.GetMethods((BindingFlags)int.MaxValue)
.Where(m => string.Equals(m.Name, methodFromType))
.ToList();
}
if (methods != null && methods.Count == 1)
{
FormatParameters(stringBuilder, methods.First());
}
else
{
stringBuilder.Append("??");
}
}
else
{
FormatParameters(stringBuilder, method);
}
stringBuilder.Append(")");
FormatFileName(stringBuilder, frame);
}