dotnet / dotnet/vscode-csharp

Debugger locals window lets me modify values that are not actually modified in the variable

Open
#5,687 0 comments 0 reactions 0 assignees View on GitHub
Debugger OmniSharp
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

Version: Latest **_everything_**

The debugger locals window does not respect the fact that its showing the user a modified value but its not actually modified in the runtime variable. As of right now, the issue seems isolated to enumerables. After investigation, the problem is the fact that the internal debug views are creating array **copies** for display instead of actually operating on the variables themselves.

Reproduction:

1. Create simplest project
2. byte[] b = new byte[42];
3. Span s = new Span(b);
4. Hit a breakpoint and expand the span in the locals. Modify one of the byte values through the span.

Actual Behavior:
The byte value is shown modified in the locals indicating to the lay user that the value is actually modified in the variable. If you then check the byte array at the same index, the value is not modified. If you then force a debug refresh through a step or the debug console, the span value at the index goes back to what it was previously.

Expected Behavior:
Two options:

1. Perform actual modification of the variable. This is linked to request: #5686
2. Omnisharp should understand which variables it can actually modify and if there is a value the user cannot modify, throw an error or don't let me modify it (make it read only).

Remarks:
Issue is not isolated to onmisharp. Visual studio has the same issue.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with a byte array, Span, a breakpoint, and the debugger locals window, then inspect the internal debug views that create array copies for display. Done means edits either modify the runtime variable or values that cannot be modified are clearly read-only or rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, typescript, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.