/// <summary> /// Uses <see cref="StackFrameParser"/> to parse a line if possible /// </summary> public bool TryParseLine(string line, [NotNullWhen(true)] out ParsedFrame?parsedFrame) { parsedFrame = null; var tree = StackFrameParser.TryParse(line); if (tree is null) { return(false); } parsedFrame = new ParsedStackFrame(tree); return(true); }
private static void Verify( string input, StackFrameMethodDeclarationNode?methodDeclaration = null, bool expectFailure = false, StackFrameFileInformationNode?fileInformation = null, StackFrameToken?eolTokenOpt = null) { FuzzyTest(input); var tree = StackFrameParser.TryParse(input); if (expectFailure) { Assert.Null(tree); return; } AssertEx.NotNull(tree); VerifyCharacterSpans(input, tree); if (methodDeclaration is null) { Assert.Null(tree.Root.MethodDeclaration); } else { StackFrameUtils.AssertEqual(methodDeclaration, tree.Root.MethodDeclaration); } if (fileInformation is null) { Assert.Null(tree.Root.FileInformationExpression); } else { StackFrameUtils.AssertEqual(fileInformation, tree.Root.FileInformationExpression); } var eolToken = eolTokenOpt.HasValue ? eolTokenOpt.Value : CreateToken(StackFrameKind.EndOfFrame, ""); StackFrameUtils.AssertEqual(eolToken, tree.Root.EndOfLineToken); }
public bool TryParseLine(VirtualCharSequence line, [NotNullWhen(true)] out ParsedFrame?parsedFrame) { // Example line: // ConsoleApp4.dll!ConsoleApp4.MyClass.ThrowAtOne() Line 19 C# // |--------------------------------| // Symbol data we care about parsedFrame = null; var startPoint = -1; for (var i = 0; i < line.Length; i++) { if (line[i].Value == '!') { // +1 here because we always want to skip the '!' character startPoint = i + 1; break; } } if (startPoint <= 0 || startPoint == line.Length) { return(false); } var textToParse = line.GetSubSequence(TextSpan.FromBounds(startPoint, line.Length)); var tree = StackFrameParser.TryParse(textToParse); if (tree is null) { return(false); } parsedFrame = new ParsedStackFrame(tree); return(true); }