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

[Debugging] Breakpoints in .razor files, which are not in the @code block won't bind #19339

Closed
mkArtakMSFT opened this issue Mar 27, 2020 · 19 comments

Comments

@mkArtakMSFT
Copy link

From @mkArtakMSFT on Thursday, March 26, 2020 7:09:38 PM

Using the latest VS preview (16.6 Preview 3) release with the latest Blazor bits (3.2-preview3):

image

Copied from original issue: dotnet/aspnetcore#20200

@mkArtakMSFT
Copy link
Author

From @mihaimyh on Thursday, March 26, 2020 9:48:24 PM

Neither those in a "code-behind" class, like FetchData.razor.cs.

@mkArtakMSFT
Copy link
Author

/cc @SteveSandersonMS

@mihaimyh
Copy link

I am not 100% sure but also debugging razor class libraries is not working. Until now I was not able to debug anything WASM related using latest WebAssembly 3.2.0 Preview 3, but I will try and see if this is just something on my side.

@lewing lewing self-assigned this Mar 27, 2020
@mkArtakMSFT mkArtakMSFT changed the title Breakpoints in .razor files, which are not in the @code block won't bind [Debugging] Breakpoints in .razor files, which are not in the @code block won't bind Mar 31, 2020
@lewing
Copy link
Member

lewing commented Apr 6, 2020

Breakpoints on the loop work fine, I'm not familiar enough with how razor sequence points map to the runtime to understand why this is failing

/cc @vargaz

@vargaz
Copy link
Contributor

vargaz commented Apr 6, 2020

Sequence point -> File/line mapping is picked up from the .pdb files. It doesn't matter whenever it is a .cs file or some other source file.

@lewing
Copy link
Member

lewing commented Apr 7, 2020

@thaystg can you look into what is going on here and why we can't hit breakpoints in the body of the razor loop.

@thaystg
Copy link
Contributor

thaystg commented Apr 8, 2020

The problem is in rzc.dll, which is responsible for generating the .g.cs file from razor file.
I used this file as an example of razor file:

https://gist.github.com/thaystg/be141b64b68c21701d796e19b4c868c6.js

Without any change in rzc.dll the generated file is like this:

__builder.AddContent(3, 
#nullable restore
#line 6 "/Users/thaysgrazia/AspNetCore/src/Components/Blazor/testassets/StandaloneApp/Pages/Counter.razor"
  currentCount == currentCount + 1

#line default
#line hidden
#nullable disable
            );

And it doesn't stop on line 6.
When I changed the rzc.dll to generate this the breakpoint works:

__builder.AddContent(3, 
#nullable restore
#line 6 "/Users/thaysgrazia/AspNetCore/src/Components/Blazor/testassets/StandaloneApp/Pages/Counter.razor"
currentCount == currentCount  + 1);
__builder.AddMarkupContent(4, "\n\n");
#nullable restore

I'm not sure exactly why, but the problem is with the generated file, I think that it's because the #line 6 and the #line hidden is in the same command, so the csc consider that the line is hidden and is not creating the right pdb, the line 6 is created as a hidden line, and that is the reason why the breakpoint doesn't stop.

image

@lewing
Copy link
Member

lewing commented Apr 9, 2020

Does #19487 help?

@thaystg
Copy link
Contributor

thaystg commented Apr 9, 2020

No, Larry, because ALL hidden breakpoints has line number= 0xfeefee, so we don't have the information of the right line number.

@lewing
Copy link
Member

lewing commented Apr 9, 2020

cc @SteveSandersonMS

@SteveSandersonMS
Copy link
Contributor

@ajaybhargavb @NTaylorMullen Does this sound like any known issue with Razor line number generation? Would you have expected this to work?

@NTaylorMullen
Copy link

@ajaybhargavb @NTaylorMullen Does this sound like any known issue with Razor line number generation? Would you have expected this to work?

Definitely would have expected this to work. Razor has been generating this way for a longggg time and we haven't changed that behavior for close to a year. We purposefully are adding the line hidden directives to ensure that you don't debug into non-visible / non-C# code.

@NTaylorMullen
Copy link

Oh and the only "known" issue in Razor line pragma generation is that we can't specify columns so occasionally things are misaligned; however, Razor's been that way since day 0 😄

@lewing
Copy link
Member

lewing commented Apr 19, 2020

@NTaylorMullen this is an entirely new debugger we're just trying to understand how to interpret what we see in the pdb

@lewing
Copy link
Member

lewing commented Nov 22, 2020

@thaystg can you see if your fixes to the sequence point choosing has resolved this?

@thaystg
Copy link
Contributor

thaystg commented Nov 22, 2020

Yes, I'll check.

@thaystg
Copy link
Contributor

thaystg commented Nov 23, 2020

No, Larry, it doesn't fix.
I tested this:

@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>
<p>Current name: @teste.getName()</p> //inserted the breakpoint here

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
	private Thays teste = new Thays();
	private int currentCount = 0;

	private void IncrementCount()
	{
		currentCount++;
	}
}

And as I expect it does not stop even when running on Blazor Server, which is a completely different debugger engine, because the cs file is generated in a way that the breakpoints are hidden, so it's impossible to stop, for wasm debugger engine and also for Blazor Server debugger engine.

@NTaylorMullen
Copy link

I think this has to be fixed on the Roslyn side. It's tracked in two locations:

@lewing
Copy link
Member

lewing commented Nov 24, 2020

I'm going to close this mono/mono issue then since we're not expecting to do any work here and the issue isn't wasm specific

@lewing lewing closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants