roslyn
roslyn copied to clipboard
Expression Evaluator Regression - Expression Evaluation in Watch seems to do not take usings into account
Version Used:
PS C:\Roslyn\roslyn> git rev-parse HEAD
9f883da6e4d576cea93d7271f3e2a52d1f2d6570

Steps to Reproduce:

1: dotnet new console
2: paste this code
using System.Linq;
while (true)
{
var list = new List<string> { "1", "2", "3", "4" };
Console.WriteLine("asd");
Thread.Sleep(500);
}
3: put this expression into watch
list.Select(x => Convert.ToInt32(x)).Where(x => x > 1).ToList()
Expected Behavior:
Returns list that contains {"2", "3", "4"}
Actual Behavior:
Returns The debugger is unable to evaluate this expression
Internally it creates this error:
(1,6): error CS1061: 'List<string>' does not contain a definition for 'Select'
and no accessible extension method 'Select' accepting a first argument of type 'List<string>'
could be found (are you missing a using directive or an assembly reference?)
My debugging attempt found that methodResolution fails (IsEmpty == true)

and then this error is generated


but I feel like that's because methods are empty when creating BoundMethodGroup

and that's because something is not found here

because NamespaceOrTypeSymbol has no informations of System.Linq in it??
I've got lost at this point
Update:
Seems like Convert.ToInt* behaves weirdly, just take a look at this example:

@tmat do you know what might be going on here. that Convert.ToDecimal works in the watch window, but Convert.ToInt32 does not is... interesting to say the least :)
The original issue says there is no accessible extension method 'Select' accepting a first argument of type 'List<string>' error, which I'd attribute to some binding issue with top-level code.
that
Convert.ToDecimalworks in the watch window, butConvert.ToInt32does not is... interesting to say the least :)
@chuckries This looks like possible VIL interpreter issue.
this repros on 17.4 p2 32803.494.main
It seems to be a lack of support on VIL for ReadOnlySpan<char> parameters, which is the case for Convert.ToInt32. This doesn't happen with Convert.ToDecimal because we hook the method with the string parameter instead. 🙂
I'll work on a fix on our side.
@isadorasophia what does 'vil' stand for? Thanks!
@CyrusNajmabadi it's a VS debugger component used for expression evaluation 😁
It seems like it's been fixed and pushed to the prod
I guess I'm closing this
