Allow use as git submodule
* build in sentry csproj * typo * public GetFrames
This commit is contained in:
parent
ef4d143d2a
commit
243029cc29
@ -74,7 +74,7 @@ namespace System.Diagnostics
|
|||||||
/// Gets the method in which the frame is executing.
|
/// Gets the method in which the frame is executing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The method in which the frame is executing.</returns>
|
/// <returns>The method in which the frame is executing.</returns>
|
||||||
public override MethodBase GetMethod() => StackFrame.GetMethod();
|
public override MethodBase? GetMethod() => StackFrame.GetMethod();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the offset from the start of the native just-in-time (JIT)-compiled code
|
/// Gets the offset from the start of the native just-in-time (JIT)-compiled code
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace System.Diagnostics
|
|||||||
{
|
{
|
||||||
public partial class EnhancedStackTrace
|
public partial class EnhancedStackTrace
|
||||||
{
|
{
|
||||||
private static readonly Type StackTraceHiddenAttributeType = Type.GetType("System.Diagnostics.StackTraceHiddenAttribute", false);
|
private static readonly Type? StackTraceHiddenAttributeType = Type.GetType("System.Diagnostics.StackTraceHiddenAttribute", false);
|
||||||
|
|
||||||
private static List<EnhancedStackFrame> GetFrames(Exception exception)
|
private static List<EnhancedStackFrame> GetFrames(Exception exception)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace System.Diagnostics
|
|||||||
return GetFrames(stackTrace);
|
return GetFrames(stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<EnhancedStackFrame> GetFrames(StackTrace stackTrace)
|
public static List<EnhancedStackFrame> GetFrames(StackTrace stackTrace)
|
||||||
{
|
{
|
||||||
var frames = new List<EnhancedStackFrame>();
|
var frames = new List<EnhancedStackFrame>();
|
||||||
var stackFrames = stackTrace.GetFrames();
|
var stackFrames = stackTrace.GetFrames();
|
||||||
@ -51,6 +51,10 @@ namespace System.Diagnostics
|
|||||||
for (var i = 0; i < stackFrames.Length; i++)
|
for (var i = 0; i < stackFrames.Length; i++)
|
||||||
{
|
{
|
||||||
var frame = stackFrames[i];
|
var frame = stackFrames[i];
|
||||||
|
if (frame is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var method = frame.GetMethod();
|
var method = frame.GetMethod();
|
||||||
|
|
||||||
// Always show last stackFrame
|
// Always show last stackFrame
|
||||||
@ -167,7 +171,7 @@ namespace System.Diagnostics
|
|||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var value = field.GetValue(field);
|
var value = field.GetValue(field);
|
||||||
if (value is Delegate d)
|
if (value is Delegate d && d.Target is not null)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(d.Method, originMethod) &&
|
if (ReferenceEquals(d.Method, originMethod) &&
|
||||||
d.Target.ToString() == originMethod.DeclaringType?.ToString())
|
d.Target.ToString() == originMethod.DeclaringType?.ToString())
|
||||||
@ -359,7 +363,7 @@ namespace System.Diagnostics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryResolveSourceMethod(IEnumerable<MethodBase> candidateMethods, GeneratedNameKind kind, string? matchHint, ref MethodBase method, ref Type type, out int? ordinal)
|
private static bool TryResolveSourceMethod(IEnumerable<MethodBase> candidateMethods, GeneratedNameKind kind, string? matchHint, ref MethodBase method, ref Type? type, out int? ordinal)
|
||||||
{
|
{
|
||||||
ordinal = null;
|
ordinal = null;
|
||||||
foreach (var candidateMethod in candidateMethods)
|
foreach (var candidateMethod in candidateMethods)
|
||||||
@ -386,6 +390,10 @@ namespace System.Diagnostics
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rawIl = methodBody.GetILAsByteArray();
|
var rawIl = methodBody.GetILAsByteArray();
|
||||||
|
if (rawIl is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var reader = new ILReader(rawIl);
|
var reader = new ILReader(rawIl);
|
||||||
while (reader.Read(candidateMethod))
|
while (reader.Read(candidateMethod))
|
||||||
{
|
{
|
||||||
@ -434,24 +442,26 @@ namespace System.Diagnostics
|
|||||||
|
|
||||||
ordinal = foundOrdinal;
|
ordinal = foundOrdinal;
|
||||||
|
|
||||||
var methods = method.DeclaringType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
var methods = method.DeclaringType?.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
||||||
|
|
||||||
var startName = method.Name.Substring(0, lamdaStart);
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var m in methods)
|
if (methods != null)
|
||||||
{
|
{
|
||||||
if (m.Name.Length > lamdaStart && m.Name.StartsWith(startName))
|
var startName = method.Name.Substring(0, lamdaStart);
|
||||||
|
foreach (var m in methods)
|
||||||
{
|
{
|
||||||
count++;
|
if (m.Name.Length > lamdaStart && m.Name.StartsWith(startName))
|
||||||
|
|
||||||
if (count > 1)
|
|
||||||
{
|
{
|
||||||
break;
|
count++;
|
||||||
|
|
||||||
|
if (count > 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (count <= 1)
|
if (count <= 1)
|
||||||
{
|
{
|
||||||
ordinal = null;
|
ordinal = null;
|
||||||
@ -600,7 +610,7 @@ namespace System.Diagnostics
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResolvedParameter GetValueTupleParameter(IList<string> tupleNames, string prefix, string name, Type parameterType)
|
private static ResolvedParameter GetValueTupleParameter(IList<string> tupleNames, string prefix, string? name, Type parameterType)
|
||||||
{
|
{
|
||||||
return new ValueTupleResolvedParameter(parameterType, tupleNames)
|
return new ValueTupleResolvedParameter(parameterType, tupleNames)
|
||||||
{
|
{
|
||||||
@ -748,7 +758,7 @@ namespace System.Diagnostics
|
|||||||
|
|
||||||
if (type.Namespace == "Ply")
|
if (type.Namespace == "Ply")
|
||||||
{
|
{
|
||||||
if (type.DeclaringType.Name == "TplPrimitives")
|
if (type.DeclaringType?.Name == "TplPrimitives")
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -788,7 +798,7 @@ namespace System.Diagnostics
|
|||||||
|
|
||||||
private static bool IsStackTraceHidden(MemberInfo memberInfo)
|
private static bool IsStackTraceHidden(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
if (!memberInfo.Module.Assembly.ReflectionOnly)
|
if (StackTraceHiddenAttributeType is not null && !memberInfo.Module.Assembly.ReflectionOnly)
|
||||||
{
|
{
|
||||||
return memberInfo.GetCustomAttributes(StackTraceHiddenAttributeType, false).Length != 0;
|
return memberInfo.GetCustomAttributes(StackTraceHiddenAttributeType, false).Length != 0;
|
||||||
}
|
}
|
||||||
@ -806,7 +816,7 @@ namespace System.Diagnostics
|
|||||||
foreach (var attribute in attributes)
|
foreach (var attribute in attributes)
|
||||||
{
|
{
|
||||||
// reflection-only attribute, match on name
|
// reflection-only attribute, match on name
|
||||||
if (attribute.AttributeType.FullName == StackTraceHiddenAttributeType.FullName)
|
if (attribute.AttributeType.FullName == StackTraceHiddenAttributeType?.FullName)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,13 +8,12 @@ using System.Text;
|
|||||||
|
|
||||||
namespace System.Diagnostics
|
namespace System.Diagnostics
|
||||||
{
|
{
|
||||||
/// <nodoc />
|
public static class ExceptionExtensions
|
||||||
public static class ExceptionExtentions
|
|
||||||
{
|
{
|
||||||
private static readonly FieldInfo stackTraceString = typeof(Exception).GetField("_stackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);
|
private static readonly FieldInfo? stackTraceString = typeof(Exception).GetField("_stackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
|
||||||
private static void SetStackTracesString(this Exception exception, string value)
|
private static void SetStackTracesString(this Exception exception, string value)
|
||||||
=> stackTraceString.SetValue(exception, value);
|
=> stackTraceString?.SetValue(exception, value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Demystifies the given <paramref name="exception"/> and tracks the original stack traces for the whole exception tree.
|
/// Demystifies the given <paramref name="exception"/> and tracks the original stack traces for the whole exception tree.
|
||||||
@ -129,7 +129,7 @@ namespace System.Diagnostics.Internal
|
|||||||
|
|
||||||
for (var i = 0; i < fields.Length; i++)
|
for (var i = 0; i < fields.Length; i++)
|
||||||
{
|
{
|
||||||
var code = (OpCode)fields[i].GetValue(null);
|
var code = (OpCode)fields[i].GetValue(null)!;
|
||||||
if (code.OpCodeType == OpCodeType.Nternal)
|
if (code.OpCodeType == OpCodeType.Nternal)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ namespace System.Diagnostics.Internal
|
|||||||
|
|
||||||
private MetadataReader? GetMetadataReader(string assemblyPath)
|
private MetadataReader? GetMetadataReader(string assemblyPath)
|
||||||
{
|
{
|
||||||
if (!_cache.TryGetValue(assemblyPath, out var provider))
|
if (!_cache.TryGetValue(assemblyPath, out var provider) && provider is not null)
|
||||||
{
|
{
|
||||||
var pdbPath = GetPdbPath(assemblyPath);
|
var pdbPath = GetPdbPath(assemblyPath);
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,9 @@ namespace System.Diagnostics.Internal
|
|||||||
|
|
||||||
private static PropertyInfo? GetTransformNamesPropertyInfo(Type attributeType)
|
private static PropertyInfo? GetTransformNamesPropertyInfo(Type attributeType)
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 8634
|
||||||
return LazyInitializer.EnsureInitialized(ref tranformerNamesLazyPropertyInfo,
|
return LazyInitializer.EnsureInitialized(ref tranformerNamesLazyPropertyInfo,
|
||||||
|
#pragma warning restore 8634
|
||||||
() => attributeType.GetProperty("TransformNames", BindingFlags.Instance | BindingFlags.Public));
|
() => attributeType.GetProperty("TransformNames", BindingFlags.Instance | BindingFlags.Public));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,7 +124,10 @@ namespace System.Diagnostics
|
|||||||
var innerType = type;
|
var innerType = type;
|
||||||
while (innerType.IsArray)
|
while (innerType.IsArray)
|
||||||
{
|
{
|
||||||
innerType = innerType.GetElementType();
|
if (innerType.GetElementType() is { } inner)
|
||||||
|
{
|
||||||
|
innerType = inner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessType(builder, innerType, options);
|
ProcessType(builder, innerType, options);
|
||||||
@ -134,21 +137,25 @@ namespace System.Diagnostics
|
|||||||
builder.Append('[');
|
builder.Append('[');
|
||||||
builder.Append(',', type.GetArrayRank() - 1);
|
builder.Append(',', type.GetArrayRank() - 1);
|
||||||
builder.Append(']');
|
builder.Append(']');
|
||||||
type = type.GetElementType();
|
if (type.GetElementType() is not { } elementType)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
type = elementType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProcessGenericType(StringBuilder builder, Type type, Type[] genericArguments, int length, DisplayNameOptions options)
|
private static void ProcessGenericType(StringBuilder builder, Type type, Type[] genericArguments, int length, DisplayNameOptions options)
|
||||||
{
|
{
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
if (type.IsNested)
|
if (type.IsNested && type.DeclaringType is not null)
|
||||||
{
|
{
|
||||||
offset = type.DeclaringType.GetGenericArguments().Length;
|
offset = type.DeclaringType.GetGenericArguments().Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.FullName)
|
if (options.FullName)
|
||||||
{
|
{
|
||||||
if (type.IsNested)
|
if (type.IsNested && type.DeclaringType is not null)
|
||||||
{
|
{
|
||||||
ProcessGenericType(builder, type.DeclaringType, genericArguments, offset, options);
|
ProcessGenericType(builder, type.DeclaringType, genericArguments, offset, options);
|
||||||
builder.Append('+');
|
builder.Append('+');
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace Ben.Demystifier.Test
|
|||||||
.ToArray())
|
.ToArray())
|
||||||
// Remove Full framework back arrow
|
// Remove Full framework back arrow
|
||||||
.Replace("<---", "");
|
.Replace("<---", "");
|
||||||
#if NET5_0 || NETCOREAPP3_1
|
#if NET5_0 || NETCOREAPP3_1 || NETCOREAPP3_0
|
||||||
var expected = string.Join("", new[] {
|
var expected = string.Join("", new[] {
|
||||||
" ---> System.ArgumentException: Value does not fall within the expected range.",
|
" ---> System.ArgumentException: Value does not fall within the expected range.",
|
||||||
" at async Task Ben.Demystifier.Test.AggregateException.Throw1()",
|
" at async Task Ben.Demystifier.Test.AggregateException.Throw1()",
|
||||||
|
|||||||
@ -109,7 +109,7 @@ namespace Ben.Demystifier.Test
|
|||||||
static Func<string, bool, (string val, bool)> s_func = (string s, bool b) => (RefMethod(s), b);
|
static Func<string, bool, (string val, bool)> s_func = (string s, bool b) => (RefMethod(s), b);
|
||||||
static string s = "";
|
static string s = "";
|
||||||
|
|
||||||
class GenericClass<T>
|
static class GenericClass<T>
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
|
||||||
public static string GenericMethod<V>(ref V value)
|
public static string GenericMethod<V>(ref V value)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ namespace Ben.Demystifier.Test
|
|||||||
stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace);
|
stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace);
|
||||||
var trace = stackTrace.Split(new[]{Environment.NewLine}, StringSplitOptions.None);
|
var trace = stackTrace.Split(new[]{Environment.NewLine}, StringSplitOptions.None);
|
||||||
|
|
||||||
#if NETCOREAPP3_1 || NET5_0
|
#if NET5_0 || NETCOREAPP3_1 || NETCOREAPP3_0
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
new[] {
|
new[] {
|
||||||
"System.Exception: Exception of type 'System.Exception' was thrown.",
|
"System.Exception: Exception of type 'System.Exception' was thrown.",
|
||||||
@ -65,7 +65,7 @@ namespace Ben.Demystifier.Test
|
|||||||
stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace);
|
stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace);
|
||||||
trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||||
|
|
||||||
#if NETCOREAPP3_1 || NET5_0
|
#if NET5_0 || NETCOREAPP3_1 || NETCOREAPP3_0
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
new[] {
|
new[] {
|
||||||
"System.Exception: Exception of type 'System.Exception' was thrown.",
|
"System.Exception: Exception of type 'System.Exception' was thrown.",
|
||||||
|
|||||||
@ -25,5 +25,5 @@ namespace Ben.Demystifier.Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Generic<T> { public struct Nested { } }
|
public static class Generic<T> { public struct Nested { } }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user