The debugger does not display values correctly after "Edit and Continue" when called directly within async Task Main.
In each example there are 2 lines of code commented out. While executing a particular snippet, debug up to var x = 5 and then uncomment the commented lines, save, and proceed to step over. In the "Examples that fail", after editing and continuing and stepping over y, it will appear as 0, and if you click the "evaluate now" button in the local or watch windows, you will receive the error, The debugger is unable to evaluate this expression. I included the Console.WriteLine to demonstrate that the value is still correctly printed to console, it's just not viewable while debugging.
Examples that work:
//works
static Task Main(string[] args)
{
var x = 5;
//var y = 6;
//Console.WriteLine(y);
return Task.FromResult(0);
}
copies from https://github.com/dotnet/corefx/issues/31241
The debugger does not display values correctly after "Edit and Continue" when called directly within async Task Main.
In each example there are 2 lines of code commented out. While executing a particular snippet, debug up to var x = 5 and then uncomment the commented lines, save, and proceed to step over. In the "Examples that fail", after editing and continuing and stepping over y, it will appear as 0, and if you click the "evaluate now" button in the local or watch windows, you will receive the error, The debugger is unable to evaluate this expression. I included the Console.WriteLine to demonstrate that the value is still correctly printed to console, it's just not viewable while debugging.
Examples that work:
//works static Task Main(string[] args) { var x = 5; //var y = 6; //Console.WriteLine(y); return Task.FromResult(0); }
//works static async Task Main(string[] args) { await Task.Yield(); Helper();
} Examples that fail:
//fails static async Task Main(string[] args) { var x = 5; //var y = 6; //Console.WriteLine(y); }
//fails static async Task Main(string[] args) { await Task.Yield(); var x = 5; //var y = 6; //Console.WriteLine(y); }