-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Cannot hit breakpoints in parameter mapped locations #43432
Comments
Does razor forward this call along to Roslyn? |
Sorry I don't understand the question, could you elaborate? |
@NTaylorMullen Is this a new problem? I'm not sure what I would have expected, but probably nothing good. One issue is that breakpoints are set on statements (which the exception of switch expressions, just recently) but you're clicking on an expression and setting a breakpoint. I'm not sure which line map would count. Tagging @tmat @ivanbasov @cston in case something to add. |
I'll investigate. |
Nope not a new problem, it's always been there since Blazor's beginnings. Something we just haven't had more time to dig into until recently 😄
❤️ 😍 💪 |
@NTaylorMullen Can you confirm where this breakpoint is supposed to be in "real" C#? Your screenshot of the // <auto-generated/>
#pragma warning disable 1591
namespace BlazorApp1.Pages
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
#nullable restore
#line 1 "e:/Scratch/BlazorApp1/_Imports.razor"
using System.Net.Http;
#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "e:/Scratch/BlazorApp1/_Imports.razor"
using Microsoft.AspNetCore.Authorization;
#line default
#line hidden
#nullable disable
#nullable restore
#line 3 "e:/Scratch/BlazorApp1/_Imports.razor"
using Microsoft.AspNetCore.Components.Authorization;
#line default
#line hidden
#nullable disable
#nullable restore
#line 4 "e:/Scratch/BlazorApp1/_Imports.razor"
using Microsoft.AspNetCore.Components.Forms;
#line default
#line hidden
#nullable disable
#nullable restore
#line 5 "e:/Scratch/BlazorApp1/_Imports.razor"
using Microsoft.AspNetCore.Components.Routing;
#line default
#line hidden
#nullable disable
#nullable restore
#line 6 "e:/Scratch/BlazorApp1/_Imports.razor"
using Microsoft.AspNetCore.Components.Web;
#line default
#line hidden
#nullable disable
#nullable restore
#line 7 "e:/Scratch/BlazorApp1/_Imports.razor"
using Microsoft.JSInterop;
#line default
#line hidden
#nullable disable
#nullable restore
#line 8 "e:/Scratch/BlazorApp1/_Imports.razor"
using BlazorApp1;
#line default
#line hidden
#nullable disable
#nullable restore
#line 9 "e:/Scratch/BlazorApp1/_Imports.razor"
using BlazorApp1.Shared;
#line default
#line hidden
#nullable disable
[Microsoft.AspNetCore.Components.RouteAttribute("/counter")]
public partial class Counter : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
#nullable restore
#line 1 "e:/Scratch/BlazorApp1/Pages/Counter.razor"
global::System.Object __typeHelper = "/counter";
#line default
#line hidden
#nullable disable
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
#nullable restore
#line 5 "e:/Scratch/BlazorApp1/Pages/Counter.razor"
__o = currentCount;
#line default
#line hidden
#nullable disable
__o = Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this,
#nullable restore
#line 7 "e:/Scratch/BlazorApp1/Pages/Counter.razor"
IncrementCount
#line default
#line hidden
#nullable disable
);
}
#pragma warning restore 1998
#nullable restore
#line 9 "e:/Scratch/BlazorApp1/Pages/Counter.razor"
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591 I don't see that physical file anywhere, so I'm guessing this is the new source generator at work? Given the above file though, it looks like Roslyn is doing the right thing. We're resolving the breakpoint for the statement I'm not exactly sure what is expected on the Razor side, and can't see too much in the debugger, but I did notice that in It then passes the mapped position from that to |
@davidwengier We disabled this in the LSP editor so that you wouldn't even get the "red" breakpoint location. Try turning off the experimental Razor editor and do the same thing (it uses a different mechanism to map breakpoints) As for what line it associates with that's: #nullable restore
#line 5 "e:/Scratch/BlazorApp1/Pages/Counter.razor"
__o = currentCount;
#line default
#line hidden At design time and at runtime that __o goes away and is replaced with all sorts of |
The IDE only sees design-time source when calculating break point locations when you place them. |
Oh totally get that part, I was more referring to what happens when the breakpoint is set to be "hit". For instance, if you use the old editor you can set a breakpoint there where as in the new editor we restricted setting the breakpoint there because we didn't want to give false hope to folks. |
Breakpoints are likely to be quite broken, especially when you start editing the files in EnC. The fact that runtime does not match design-time will definitely throw it off. |
Sure but it works for all sorts of other things where it doesn't match 😄 |
Not sure what you mean. I'm just saying that we need to review EnC and see if its active statement mapping works for |
Alright, I'll turn off the LSP editor and see if that reveals any secrets. It's worth nothing I wasn't doing any of this at runtime, this was just opening the razor file in the editor and hitting F9. Let me know if thats not the right repro. |
Alright, apologies for my confusion, the issue is at runtime the breakpoints aren't hit. The inability to create them in the LSP editor is a known thing that is irrelevant for this bug, for all intents and purposes. |
This behavior in C# compiler is by design. The code that Razor emits can't work.
|
To achieve the desired behavior we would need a new C# language feature:
and then Razor could emit something like
|
BTW, |
Ahhhh ok ya that sounds like a super awesome idea and also makes me think about #46526 too |
This ends up impacting Blazor scenarios where Blazor generates
@currentCount
as:And then attempting to set a breakpoints results in a failure to bind or step over:
/cc @tmat
The text was updated successfully, but these errors were encountered: