Skip to content

Safely create VirtualCharSequence from string in StackFrameParser #59283

Closed
ryzngard wants to merge 18 commits into
dotnet:mainfrom
ryzngard:issues/59258_stack_parse_assert
Closed

Safely create VirtualCharSequence from string in StackFrameParser #59283
ryzngard wants to merge 18 commits into
dotnet:mainfrom
ryzngard:issues/59258_stack_parse_assert

Conversation

@ryzngard
Copy link
Copy Markdown
Contributor

@ryzngard ryzngard commented Feb 4, 2022

Fixes #59258

@ryzngard ryzngard requested a review from a team as a code owner February 4, 2022 19:03
@ghost ghost added the Area-IDE label Feb 4, 2022
/// <returns></returns>
public static VirtualChar CreateNextInString(string text, int index, Func<int, int, TextSpan> createSpan, out int consumedCharacters)
{
if (Rune.TryCreate(text[index], out var rune))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ported from AbstractVirtualCharService.cs

Comment thread src/Features/Core/Portable/EmbeddedLanguages/StackFrame/StackFrameLexer.cs Outdated
ryzngard and others added 5 commits February 4, 2022 17:04
…rameLexer.cs

Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
…ddedLanguages/VirtualChars/VirtualCharSequence.cs

Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Comment thread src/EditorFeatures/Test/EmbeddedLanguages/StackFrame/StackFrameParserTests.cs Outdated
@ryzngard
Copy link
Copy Markdown
Contributor Author

ryzngard commented Feb 8, 2022

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@ryzngard
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@JoeRobich
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

Comment on lines 180 to 181

index += ConvertTextAtIndexToRune(tokenText, index, result, offset);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to already be handled by the else clause that you added. By having it here this code is executing twice and some of the text is not covered by the earlier quote and brace checks.

Suggested change
index += ConvertTextAtIndexToRune(tokenText, index, result, offset);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure I follow. If we move the characters by a certain amount the index will always need to be added to. CreateNextInString will consume some number of characters to produce a virtualChar. That's separate from ConvertTextAtIndexToRune

@ryzngard ryzngard closed this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion in StackFrameParser

4 participants