Skip to content

Commit e84a866

Browse files
authored
Merge pull request #11 from MaceWindu/master
Release 1.0.0
2 parents 26ae987 + 6697ae9 commit e84a866

36 files changed

Lines changed: 603 additions & 693 deletions

Directory.Packages.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project>
2+
<ItemGroup>
3+
<PackageVersion Include="esprima" Version="2.0.0" />
4+
<PackageVersion Include="System.Text.Json" Version="5.0.2" />
5+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
6+
<PackageVersion Include="NUnit3TestAdapter" Version="4.0.0" />
7+
<PackageVersion Include="NUnit" Version="3.13.2" />
8+
<PackageVersion Include="Moq" Version="4.16.1" />
9+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
10+
</ItemGroup>
11+
</Project>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ TypeError: Cannot read property 'length' of undefined
149149
The top level API for call stack deminification is the `StackTraceDeminifier.DeminifyStackTrace` method. For each url that appears in a JavaScript callstack, the library requires the contents of the JavaScript file and corresponding source map in order to determine the original method name and code location. This information is provided by the consumer of the API by implementing the `ISourceMapProvider` and `ISourceCodeProvider` interfaces. These interfaces are expected to return a `Stream` that can be used to access the contents of the requested JavaScript code or corresponding source map. A `StackTraceDeminifier` can be instantiated using one of the methods on `StackTraceDeminfierFactory`. A sample usage of the library is shown below.
150150

151151
```csharp
152-
StackTraceDeminifier sourceMapCallstackDeminifier = StackTraceDeminfierFactory.GetStackTraceDeminfier(new SourceMapProvider(), new SourceCodeProvider());
152+
StackTraceDeminifier sourceMapCallstackDeminifier = StackTraceDeminifierFactory.GetStackTraceDeminfier(new SourceMapProvider(), new SourceCodeProvider());
153153
DeminifyStackTraceResult deminifyStackTraceResult = sourceMapCallstackDeminifier.DeminifyStackTrace(callstack);
154154
string deminifiedCallstack = deminifyStackTraceResult.ToString();
155155
```

Shared.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@
2929
<AnalysisLevel>preview</AnalysisLevel>
3030
<EnableNETAnalyzers>true</EnableNETAnalyzers>
3131
<RunAnalyzers>true</RunAnalyzers>
32+
33+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
3234
</PropertyGroup>
3335
</Project>

SourcemapTools.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{38BD9C43-B
1313
.gitattributes = .gitattributes
1414
.gitignore = .gitignore
1515
CONTRIBUTING.md = CONTRIBUTING.md
16+
Directory.Packages.props = Directory.Packages.props
1617
LICENSE.txt = LICENSE.txt
1718
Package.nuspec = Package.nuspec
1819
README.md = README.md

ci/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variables:
66
- name: assemblyVersion
77
value: 1.0.0
88
- name: packageVersion
9-
value: 1.0.0-rc.3
9+
value: 1.0.0
1010
- name: nugetDevVersion
1111
value: 1.0.0
1212

src/SourceMapTools/CallstackDeminifier/AllAstVisitor.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SourcemapToolkit.CallstackDeminifier
1111
// should be removed if https://github.com/sebastienros/esprima-dotnet/pull/148 accepted
1212
internal class AllAstVisitor
1313
{
14-
private readonly List<Node> _parentStack = new List<Node>();
14+
private readonly List<Node> _parentStack = new ();
1515
protected IReadOnlyList<Node> ParentStack => _parentStack;
1616

1717
/// <summary>
@@ -240,6 +240,9 @@ public virtual void Visit(Node node)
240240
case Nodes.ClassExpression:
241241
VisitClassExpression(node.As<ClassExpression>());
242242
break;
243+
case Nodes.ChainExpression:
244+
VisitChainExpression(node.As<ChainExpression>());
245+
break;
243246
default:
244247
VisitUnknownNode(node);
245248
break;
@@ -248,6 +251,11 @@ public virtual void Visit(Node node)
248251
_parentStack.RemoveAt(_parentStack.Count - 1);
249252
}
250253

254+
protected virtual void VisitChainExpression(ChainExpression chainExpression)
255+
{
256+
Visit(chainExpression.Expression);
257+
}
258+
251259
protected virtual void VisitProgram(Program program)
252260
{
253261
VisitNodeList(program.Body);
@@ -260,7 +268,10 @@ protected virtual void VisitUnknownNode(Node node)
260268

261269
protected virtual void VisitCatchClause(CatchClause catchClause)
262270
{
263-
Visit(catchClause.Param);
271+
if (catchClause.Param != null)
272+
{
273+
Visit(catchClause.Param);
274+
}
264275
Visit(catchClause.Body);
265276
}
266277

src/SourceMapTools/CallstackDeminifier/StackFrameDeminifier.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ public StackFrameDeminifier(ISourceMapStore sourceMapStore, IFunctionMapStore fu
2929
/// <returns>Returns a StackFrameDeminificationResult that contains a stack trace that has been translated to the original source code. The DeminificationError Property indicates if the StackFrame could not be deminified. DeminifiedStackFrame will not be null, but any properties of DeminifiedStackFrame could be null if the value could not be extracted. </returns>
3030
StackFrameDeminificationResult IStackFrameDeminifier.DeminifyStackFrame(StackFrame stackFrame, string? callerSymbolName)
3131
{
32-
if (stackFrame == null)
33-
{
34-
throw new ArgumentNullException(nameof(stackFrame));
35-
}
36-
3732
var sourceMap = _sourceMapStore.GetSourceMapForUrl(stackFrame.FilePath);
3833
var generatedSourcePosition = stackFrame.SourcePosition;
3934

src/SourceMapTools/CallstackDeminifier/StackTraceParser.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ IReadOnlyList<StackFrame> IStackTraceParser.ParseStackTrace(string stackTraceStr
4747
/// </returns>
4848
public virtual IReadOnlyList<StackFrame> ParseStackTrace(string stackTraceString, out string? message)
4949
{
50-
if (stackTraceString == null)
51-
{
52-
throw new ArgumentNullException(nameof(stackTraceString));
53-
}
54-
5550
message = null;
5651

5752
var stackFrameStrings = stackTraceString.SplitFast('\n');
@@ -137,11 +132,6 @@ public virtual IReadOnlyList<StackFrame> ParseStackTrace(string stackTraceString
137132
/// </summary>
138133
protected internal virtual StackFrame? TryParseSingleStackFrame(string frame)
139134
{
140-
if (frame == null)
141-
{
142-
throw new ArgumentNullException(nameof(frame));
143-
}
144-
145135
var lineNumberMatch = _lineNumberRegex.Match(frame);
146136

147137
if (!lineNumberMatch.Success)

src/SourceMapTools/SourcemapParser/MappingEntry.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace SourcemapToolkit.SourcemapParser
1+
using System.Diagnostics;
2+
3+
namespace SourcemapToolkit.SourcemapParser
24
{
35
/// <summary>
46
/// Source map entry.
57
/// </summary>
8+
[DebuggerDisplay("(Column: {GeneratedSourcePosition.Column}, Line: {GeneratedSourcePosition.Line}): {OriginalName}")]
69
public struct MappingEntry
710
{
811
/// <summary>

src/SourceMapTools/SourcemapParser/SourceMap.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ public SourceMap Clone()
114114
/// </summary>
115115
public SourceMap ApplySourceMap(SourceMap submap, string? sourceFile = null)
116116
{
117-
if (submap == null)
118-
{
119-
throw new ArgumentNullException(nameof(submap));
120-
}
121-
122117
if (sourceFile == null)
123118
{
124119
if (submap.File == null)

0 commit comments

Comments
 (0)