dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.97k stars 4.65k forks source link

Blazor webassembly does not hit breakpoints on <select> bindings #104231

Closed PKOITC closed 1 month ago

PKOITC commented 2 months ago

When debugging blazor webassembly breakpoints are not beeing hit if call is originating form a <select> @bind.

Example:

@page "/"

<select class="form-control form-control-sm" @bind="Color">
    <option value="Blue">Blue</option>
    <option value="Black">Black</option>
</select>

<input type="number" @bind="Value" />

@code{

    string _color;
    string Color
    {
        get
        {
            return _color;
        }
        set
        {
            Console.WriteLine("SET 'Color'. This will NOT be hit !");
            System.Diagnostics.Debugger.Break();
            if (_color != value)
            {
                _color = value;
            }
        }
    }

    decimal? _value;
    decimal? Value
    {
        get
        {
            return _value;
        }
        set
        {
            Console.WriteLine("SET 'Value'. This WILL be hit !");
            System.Diagnostics.Debugger.Break();
            if (_value != value)
            {
                _value = value;
            }
        }
    }
}
davidwengier commented 2 months ago

Confirmed this is happening for me too. Works fine in a server app, and its not a tooling issue (breakpoints bind correctly etc.). Suspect this is an issue in the Blazor WASM javacsript framework bits. Moving to runtime.

dotnet-policy-service[bot] commented 2 months ago

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

thaystg commented 2 months ago

Hi, is your project targeting .net9? Can you please install VS 17.11 Preview 2 and enable this option? "Enable new .NET 8+ Mono debugger (preview)" Please let me know if it works.

thaystg commented 1 month ago

This is fixed using the new debugger.