dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.11k stars 4.04k forks source link

Microsoft.VisualBasic.dll is not loaded by code typed in the immediate window #19526

Open ivanbasov opened 7 years ago

ivanbasov commented 7 years ago

Attempted to migrate the test to xUnit. Still see the same issue. That is, I can reproduce it locally without any frameworks. It is not caused by Tao. It seems to be a regression in VB compiler services.

Here is a repro scenario:

  1. Create a VB console application with the code.
    Module Module1
    Sub Main()
        'Dim x = (Function(val) (val + val))(1)
        System.Diagnostics.Debugger.Break()
    End Sub
    End Module
  2. Start debugging up to the breakpoint.
  3. Type ?(Function(val) (val + val))(1) in the immediate window. Expected 2 Actual error BC35000: Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.Operators.AddObject' is not defined.
  4. Also Microsoft.VisualBasic.dll is not loaded in Debug -> Modules.
  5. Uncomment the line in the code and run it again.
  6. ?(Function(val) (val + val))(1) will work in the immediate window.
  7. Microsoft.VisualBasic.dll will be loaded in Debug -> Modules.

Trying to add a reference explicityl, you would get the following message

A reference to 'Microsoft.VisualBasic' could not be added. This component is already automatically referenced by the build system.

Based on https://github.com/dotnet/roslyn/issues/8724 Will migrate tests for #8724 from Tao to xUnit but keep the failing one skipped for a while.

jinujoseph commented 7 years ago

Tracked here

sharwell commented 1 year ago

This issue is different from the linked issue. I'm modifying the integration test to use this expression:

(Function(val As Integer) (val + val))(1)

The original expression (where val is not typed as Integer) cannot be evaluated by the debugger expression evaluator. This issue tracks that specific failure.