-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from MaceWindu/master
Release 1.0.0 RC3
- Loading branch information
Showing
43 changed files
with
1,400 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 34 additions & 9 deletions
43
src/SourceMapTools/CallstackDeminifier/DeminifyStackTraceResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using SourcemapToolkit.SourcemapParser; | ||
|
||
namespace SourcemapToolkit.CallstackDeminifier | ||
{ | ||
/// <summary> | ||
/// Contains stack trace details (both minified and diminified). | ||
/// </summary> | ||
public class DeminifyStackTraceResult | ||
{ | ||
internal DeminifyStackTraceResult( | ||
string? message, | ||
IReadOnlyList<StackFrame> minifiedStackFrames, | ||
IReadOnlyList<StackFrameDeminificationResult> deminifiedStackFrameResults, | ||
string? message) | ||
IReadOnlyList<StackFrameDeminificationResult> deminifiedStackFrameResults) | ||
{ | ||
MinifiedStackFrames = minifiedStackFrames; | ||
DeminifiedStackFrameResults = deminifiedStackFrameResults; | ||
Message = message; | ||
} | ||
|
||
/// <summary> | ||
/// Gets error message, associated with stack trace. | ||
/// </summary> | ||
public string? Message { get; } | ||
|
||
/// <summary> | ||
/// Gets list of stack frames for minified stack. | ||
/// </summary> | ||
public IReadOnlyList<StackFrame> MinifiedStackFrames { get; } | ||
|
||
/// <summary> | ||
/// Gets list of stack frames for de-minified stack. | ||
/// </summary> | ||
public IReadOnlyList<StackFrameDeminificationResult> DeminifiedStackFrameResults { get; } | ||
|
||
/// <summary> | ||
/// Returns string that represents stack trace | ||
/// </summary> | ||
public override string ToString() | ||
{ | ||
var output = Message ?? string.Empty; | ||
var sb = new StringBuilder(); | ||
|
||
if (!string.IsNullOrEmpty(Message)) | ||
{ | ||
sb.Append(Message); | ||
} | ||
|
||
for (var i = 0; i < DeminifiedStackFrameResults.Count; i++) | ||
{ | ||
var deminFrame = DeminifiedStackFrameResults[i].DeminifiedStackFrame; | ||
|
||
// Use deminified info wherever possible, merging if necessary so we always print a full frame | ||
var frame = new StackFrame( | ||
deminFrame.MethodName ?? MinifiedStackFrames[i].MethodName, | ||
deminFrame.SourcePosition != null ? deminFrame.FilePath : MinifiedStackFrames[i].FilePath, | ||
deminFrame.SourcePosition ?? MinifiedStackFrames[i].SourcePosition); | ||
deminFrame.SourcePosition != SourcePosition.NotFound ? deminFrame.FilePath : MinifiedStackFrames[i].FilePath, | ||
deminFrame.SourcePosition != SourcePosition.NotFound ? deminFrame.SourcePosition : MinifiedStackFrames[i].SourcePosition); | ||
|
||
output += $"{Environment.NewLine} {frame}"; | ||
sb | ||
.AppendLine() | ||
.Append(" ") | ||
.Append(frame); | ||
} | ||
|
||
return output; | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/SourceMapTools/CallstackDeminifier/IReadOnlyListExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace SourcemapToolkit.SourcemapParser | ||
{ | ||
internal static class IReadOnlyListExtensions | ||
{ | ||
public static int IndexOf<T>(this IReadOnlyList<T> input, T value) | ||
{ | ||
var equalityComparer = EqualityComparer<T>.Default; | ||
for (var i = 0; i < input.Count; i++) | ||
{ | ||
if (equalityComparer.Equals(input[i], value)) | ||
{ | ||
return i; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
/// <summary> | ||
/// Copied from: https://referencesource.microsoft.com/#mscorlib/system/collections/generic/arraysorthelper.cs,63a9955a91f2b37b | ||
/// </summary> | ||
public static int BinarySearch<T>(this IReadOnlyList<T> input, T item, IComparer<T> comparer) | ||
{ | ||
var lo = 0; | ||
var hi = input.Count - 1; | ||
|
||
while (lo <= hi) | ||
{ | ||
var i = lo + ((hi - lo) >> 1); | ||
var order = comparer.Compare(input[i], item); | ||
|
||
if (order == 0) | ||
{ | ||
return i; | ||
} | ||
|
||
if (order < 0) | ||
{ | ||
lo = i + 1; | ||
} | ||
else | ||
{ | ||
hi = i - 1; | ||
} | ||
} | ||
|
||
return ~lo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.