Skip to content

Watch window does not execute ToString() on objects #49143

Closed
@RobertBouillon

Description

@RobertBouillon

Describe the bug

The watch window doesn't execute the ToString() method in Blazor WASM, which is valuable in debugging to inspect identifying properties of an object without having to expand it, especially when the objects are members of a collection.

To Reproduce

  1. Create a new Blazor WASM project
  2. Add a new .NET library project to the solution
  3. Add the Foo and Something classes 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 property
  7. Start debugging
  8. Click on the "Fetch Data" link in the window
  9. The program should break in the Foo class. Open the locals Window

Expected Results

The What property shows the result of ToString (Name of Something)
image
(Image shown is the locals window when the same value is viewed from a console project)

Actual Results

The What property shows the name of the type (BlazorBugsLib.Something)
image

Foo.cs

using System;

namespace BlazorBugsLib
{
  public class Foo
  {
    public string Bar => "sample-data/weather.json";
    public string Lorem { get; set; } = "Safe";
    public string Ipsum { get; set; } = "Side";
    public Something What { get; } = new Something();
  }

  public class Something
  {
    public string Name { get; set; }
    public Something() => Name = "Name of something";
    public override string ToString() => Name;
  }
}

FetchData.razor

  protected override async Task OnInitializedAsync()
  {
    forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>(new BlazorBugsLib.Foo().Bar);
  }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions