Skip to content

Commit

Permalink
Simplify FrameData
Browse files Browse the repository at this point in the history
  • Loading branch information
mausworks committed Mar 5, 2018
1 parent 387b4c7 commit 4f74611
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/Pidget.Client/DataModels/FrameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace Pidget.Client.DataModels
{
public class FrameData
{
private const string UnknownMemberReplacement = "(unknown)";

[JsonProperty("abs_path")]
public string AbsolutePath { get; set; }

Expand Down Expand Up @@ -45,20 +43,15 @@ public static FrameData FromStackFrame(StackFrame stackFrame)
LineNumber = GetLineNumber(stackFrame),
ColumnNumber = stackFrame.GetFileColumnNumber(),
InApp = IsInApp(method),
Module = GetModule(method),
Function = GetMethodName(method),
ContextLine = GetMethodSource(method)
Module = method.DeclaringType.FullName,
Function = method.Name,
ContextLine = method.ToString()
};
}

private static bool IsInApp(MethodBase method)
{
if (method == null)
{
return true;
}

var module = GetModule(method);
var module = method.DeclaringType.FullName;

return !module.StartsWith("System.", StringComparison.Ordinal)
&& !module.StartsWith("Microsoft.", StringComparison.Ordinal);
Expand All @@ -71,17 +64,5 @@ private static int GetLineNumber(StackFrame stackFrame)
return lineNumber != 0 ? lineNumber
: stackFrame.GetILOffset();
}

private static string GetMethodSource(MethodBase method)
=> method?.ToString()
?? UnknownMemberReplacement;

private static string GetMethodName(MethodBase method)
=> method?.Name
?? UnknownMemberReplacement;

private static string GetModule(MethodBase method)
=> method?.DeclaringType.FullName
?? UnknownMemberReplacement;
}
}

0 comments on commit 4f74611

Please sign in to comment.