Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor WASM doesn't correctly step through code when debugging #49141

Closed
RobertBouillon opened this issue Mar 4, 2021 · 7 comments · Fixed by #55915
Closed

Blazor WASM doesn't correctly step through code when debugging #49141

RobertBouillon opened this issue Mar 4, 2021 · 7 comments · Fixed by #55915
Assignees
Labels
arch-wasm WebAssembly architecture area-Debugger-mono
Milestone

Comments

@RobertBouillon
Copy link

Describe the bug

Stepping through code acts unpredictably, sometimes skipping over expressions that should be hit.

Workaround

You can guarantee that code will stop on a given line by adding a breakpoint. Because STEP OVER acts so unpredictably, adding a breakpoint is really the only way you can guarantee that your code is going to stop on a given line.

To Reproduce

  1. Create a new Blazor WASM project
  2. Add a new .NET library project to the solution
  3. Add the Foo class to the library with the code below
  4. Add a reference to the .NET library project from the WASM project
  5. Update the FetchData.razor page with the code below.
  6. Add a breakpoint in the Bar method of the Foo class on the line with ret = 0
  7. Start debugging
  8. Click on the "Fetch Data" link in the window
  9. The program should break in the Foo class.
  10. Press F10 (or invoke the STEP OVER VS debug command)

Expected Results

The currently executing line will progress will progress to the line with return ret;

Actual Results

The debugger steps out of the function

Foo.cs

using System;
using System.Linq;
using System.Collections.Generic;

namespace BlazorBugsLib
{
  public class Foo
  {
    public string Lorem { get; set; } = "Safe";
    public int Bar()
    {
      int ret;
      if (Lorem.StartsWith('S'))
        ret = 0;
      else
        ret = 1;

      return ret;
    }
  }
}

FetchData.razor

  protected override async Task OnInitializedAsync()
  {
    Console.WriteLine(new BlazorBugsLib.Foo().Bar());
    forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("Bad URI");
  }
@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/aspnetcore Mar 4, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner labels Mar 4, 2021
@ghost
Copy link

ghost commented Mar 4, 2021

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

Describe the bug

Stepping through code acts unpredictably, sometimes skipping over expressions that should be hit.

Workaround

You can guarantee that code will stop on a given line by adding a breakpoint. Because STEP OVER acts so unpredictably, adding a breakpoint is really the only way you can guarantee that your code is going to stop on a given line.

To Reproduce

  1. Create a new Blazor WASM project
  2. Add a new .NET library project to the solution
  3. Add the Foo class to the library with the code below
  4. Add a reference to the .NET library project from the WASM project
  5. Update the FetchData.razor page with the code below.
  6. Add a breakpoint in the Bar method of the Foo class on the line with ret = 0
  7. Start debugging
  8. Click on the "Fetch Data" link in the window
  9. The program should break in the Foo class.
  10. Press F10 (or invoke the STEP OVER VS debug command)

Expected Results

The currently executing line will progress will progress to the line with return ret;

Actual Results

The debugger steps out of the function

Foo.cs

using System;
using System.Linq;
using System.Collections.Generic;

namespace BlazorBugsLib
{
  public class Foo
  {
    public string Lorem { get; set; } = "Safe";
    public int Bar()
    {
      int ret;
      if (Lorem.StartsWith('S'))
        ret = 0;
      else
        ret = 1;

      return ret;
    }
  }
}

FetchData.razor

  protected override async Task OnInitializedAsync()
  {
    Console.WriteLine(new BlazorBugsLib.Foo().Bar());
    forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("Bad URI");
  }
Author: RobertBouillon
Assignees: -
Labels:

area-Diagnostics-coreclr, untriaged

Milestone: -

@mkArtakMSFT
Copy link
Member

Thanks for detailed issue report, @RobertBouillon.
@lewing FYI

@ghost
Copy link

ghost commented Mar 4, 2021

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

Describe the bug

Stepping through code acts unpredictably, sometimes skipping over expressions that should be hit.

Workaround

You can guarantee that code will stop on a given line by adding a breakpoint. Because STEP OVER acts so unpredictably, adding a breakpoint is really the only way you can guarantee that your code is going to stop on a given line.

To Reproduce

  1. Create a new Blazor WASM project
  2. Add a new .NET library project to the solution
  3. Add the Foo class to the library with the code below
  4. Add a reference to the .NET library project from the WASM project
  5. Update the FetchData.razor page with the code below.
  6. Add a breakpoint in the Bar method of the Foo class on the line with ret = 0
  7. Start debugging
  8. Click on the "Fetch Data" link in the window
  9. The program should break in the Foo class.
  10. Press F10 (or invoke the STEP OVER VS debug command)

Expected Results

The currently executing line will progress will progress to the line with return ret;

Actual Results

The debugger steps out of the function

Foo.cs

using System;
using System.Linq;
using System.Collections.Generic;

namespace BlazorBugsLib
{
  public class Foo
  {
    public string Lorem { get; set; } = "Safe";
    public int Bar()
    {
      int ret;
      if (Lorem.StartsWith('S'))
        ret = 0;
      else
        ret = 1;

      return ret;
    }
  }
}

FetchData.razor

  protected override async Task OnInitializedAsync()
  {
    Console.WriteLine(new BlazorBugsLib.Foo().Bar());
    forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("Bad URI");
  }
Author: RobertBouillon
Assignees: -
Labels:

area-Debugger-mono, area-Diagnostics-coreclr, untriaged

Milestone: -

@tommcdon tommcdon added arch-wasm WebAssembly architecture and removed area-Diagnostics-coreclr labels Mar 4, 2021
@ghost
Copy link

ghost commented Mar 4, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Describe the bug

Stepping through code acts unpredictably, sometimes skipping over expressions that should be hit.

Workaround

You can guarantee that code will stop on a given line by adding a breakpoint. Because STEP OVER acts so unpredictably, adding a breakpoint is really the only way you can guarantee that your code is going to stop on a given line.

To Reproduce

  1. Create a new Blazor WASM project
  2. Add a new .NET library project to the solution
  3. Add the Foo class to the library with the code below
  4. Add a reference to the .NET library project from the WASM project
  5. Update the FetchData.razor page with the code below.
  6. Add a breakpoint in the Bar method of the Foo class on the line with ret = 0
  7. Start debugging
  8. Click on the "Fetch Data" link in the window
  9. The program should break in the Foo class.
  10. Press F10 (or invoke the STEP OVER VS debug command)

Expected Results

The currently executing line will progress will progress to the line with return ret;

Actual Results

The debugger steps out of the function

Foo.cs

using System;
using System.Linq;
using System.Collections.Generic;

namespace BlazorBugsLib
{
  public class Foo
  {
    public string Lorem { get; set; } = "Safe";
    public int Bar()
    {
      int ret;
      if (Lorem.StartsWith('S'))
        ret = 0;
      else
        ret = 1;

      return ret;
    }
  }
}

FetchData.razor

  protected override async Task OnInitializedAsync()
  {
    Console.WriteLine(new BlazorBugsLib.Foo().Bar());
    forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("Bad URI");
  }
Author: RobertBouillon
Assignees: -
Labels:

arch-wasm, area-Debugger-mono, untriaged

Milestone: -

@lewing
Copy link
Member

lewing commented Mar 5, 2021

cc @radical

@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Mar 6, 2021
@lewing lewing added this to the 6.0.0 milestone Mar 6, 2021
@lewing
Copy link
Member

lewing commented Jun 28, 2021

@thaystg is this fixed now?

@thaystg
Copy link
Member

thaystg commented Jul 19, 2021

Yes.

@thaystg thaystg closed this as completed Jul 19, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 19, 2021
thaystg added a commit to thaystg/runtime that referenced this issue Jul 19, 2021
thaystg added a commit that referenced this issue Jul 21, 2021
* Creating test to close 49143.

* Creating test to close #49141

* Adding test for #49218.

* Fix behavior of step to be the same of what we see when debugging using debugger-libs+mono or coreclr.
Fix error message of evaluate calling methods.
Adding test for #49142

* Improving test to test what @radical asked.

* Changing what was suggested by @radical.
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 21, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Debugger-mono
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants