dotnet / dotnet/vscode-csharp

Locals does not work when debugging : `error CS0103: The name 'i' does not exist in the current context` even when the variable is already set in the context

Open
#5,689 1 comment 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

## Environment data
`dotnet --info` output:

`dotnet --info`

```
.NET SDK (reflecting any global.json):
Version: 6.0.407
Commit: d8659ea151

Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: ubuntu.22.04-x64
Base Path: /home/castello/.dotnet/sdk/6.0.407/

Host:
Version: 7.0.4
Architecture: x64
Commit: 0a396acafe

.NET SDKs installed:
6.0.407 [/home/castello/.dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.15 [/home/castello/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.4 [/home/castello/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.15 [/home/castello/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.4 [/home/castello/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

VS Code version: 1.78.2
C# Extension version: v1.25.7

## OmniSharp log

OmniSharp log

```
Starting OmniSharp server at 5/22/2023, 10:59:14 PM
Target: /home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.sln

OmniSharp server started with .NET 6.0.407
.
Path: /home/castello/.vscode-server/extensions/ms-dotnettools.csharp-1.25.7-linux-x64/.omnisharp/1.39.6-net6.0/OmniSharp.dll
PID: 17772

[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.407 17.3.2 - "/home/castello/.dotnet/sdk/6.0.407/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.407 17.3.2 - "/home/castello/.dotnet/sdk/6.0.407/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/castello/tmp/vscode/gpu/dotnetunodue'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.sln'.
[warn]: OmniSharp.MSBuild.ProjectSystem
Found project that doesn't exist on disk: /home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.UWP/dotnetunodue.Uwp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/castello/tmp/vscode/gpu/dotnetunodue'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/castello/tmp/vscode/gpu/dotnetunodue' on host 17361.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: dotnetunodue.Skia.Gtk
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj
Received response for /v2/getcodeactions but could not find request.
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/castello/tmp/vscode/gpu/dotnetunodue/dotnetunodue.Skia.Gtk/dotnetunodue.Skia.Gtk.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Update project: dotnetunodue.Skia.Gtk
Received response for /findusages but could not find request.
Received response for /findusages but could not find request.

```

## Steps to reproduce

1. Create a Uno Platform application;
1. Start debugging session;
3. Try to watch or solve expression using local variables;

## Expected behavior

Local variables being shown, expressions from `DEBUG CONSOLE` tab solved for local variables.

## Actual behavior

When debugging the `Locals` variables are not filled as expected and when trying to solve expressions using these local variables shown error `CS0103`:

![image](https://github.com/OmniSharp/omnisharp-vscode/assets/2633321/e7223703-bac2-4714-8a6a-e5c97cb881ae)

## Additional context

`launch.json`

```json
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Debug Local",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-torizon-local",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/dotnetunodue.Skia.Gtk/bin/Debug/net6.0/dotnetunodue.Skia.Gtk.dll",
"args": [],
"env": {
"DOTNET_MODIFIABLE_ASSEMBLIES": "debug",
"GDK_BACKEND": "x11",
"UNO_FULLSCREEN": "false"
},
"cwd": "${workspaceFolder}/dotnetunodue.Skia.Gtk",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.