dotnet / runtime

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

Using ApplyUpdate for Hot Reload shows stack traces not mappable to source #56335

Open vritant24 opened 3 years ago

vritant24 commented 3 years ago

Description

For a following line of code:

public void TestAreEqual()
{
    Assert.AreEqual(2, 0);
}

The Stack Trace is

Message: 
Assert.AreEqual failed. Expected:<2>. Actual:<0>. 

Stack Trace: 
CalculatorTests.TestAreEqual() line 36

But when changed to the following snippet and hot reload the changes,

public void TestAreEqual()
{
    Assert.AreEqual(2, 1);
}

The stack trace changes to:

Message: 
Assert.AreEqual failed. Expected:<2>. Actual:<1>. 

Stack Trace: 
TestAreEqual() in MSTestProject.dll:token 0x6000006+0x1

The updates in this case are being retrieved from the EnC Hot reload service and all the medataDelta, the ilDelta and the pdbDelta are being correctly passed into the AssemblyExtensions.ApplyUpdate api.

Configuration

Using .NET 6.0.100-preview.6.21355.2 Windows 10

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

hoyosjs commented 3 years ago

@vritant24 does this happen for both mono and CoreCLR?

ghost commented 3 years ago

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

Issue Details
### Description For a following line of code: ```cs public void TestAreEqual() { Assert.AreEqual(2, 0); } ``` The Stack Trace is ```cs Message:  Assert.AreEqual failed. Expected:<2>. Actual:<0>. Stack Trace:  CalculatorTests.TestAreEqual() line 36 ``` But when changed to the following snippet and hot reload the changes, ```cs public void TestAreEqual() { Assert.AreEqual(2, 1); } ``` The stack trace changes to: ```cs Message:  Assert.AreEqual failed. Expected:<2>. Actual:<1>. Stack Trace:  TestAreEqual() in MSTestProject.dll:token 0x6000006+0x1 ``` The updates in this case are being retrieved from the EnC Hot reload service and all the `medataDelta`, the `ilDelta` and the `pdbDelta` are being correctly passed into the `AssemblyExtensions.ApplyUpdate` api. ### Configuration Using .NET 6.0.100-preview.6.21355.2 Windows 10
Author: vritant24
Assignees: -
Labels: `area-Diagnostics-coreclr`, `untriaged`
Milestone: -
hoyosjs commented 3 years ago

cc: @mikem8361

vritant24 commented 3 years ago

@vritant24 does this happen for both mono and CoreCLR?

I haven’t given this a try in Mono as my scenario only involves coreCLR. For context I’m running into this in VS as part of the Hot Reload in test execution experience.

noahfalk commented 3 years ago

@mikem8361 - Triage this to 7.0 if it doesn't fit. This was a known limitation for ENC and I am guessing nothing has been implemented at this point to resolve it for Hot Reload? With ENC it wasn't possible because the runtime didn't have access to the modified PDB. Now with Hot Reload we do have the delta so it is plausible we could resolve this with enough work.

mikem8361 commented 3 years ago

Moved to 7.0 given that the scope of this work won't fit in 6.0.

lambdageek commented 3 years ago

(Adding myself, because it's probably broken in Mono, too)

vritant24 commented 2 years ago

Will this not be done in the .NET 7 timeframe?

mikem8361 commented 2 years ago

No, this will not fix in our .NET 7 schedule.

MarcinZiabek commented 1 month ago

Are there any plans to cover this enhancement in the dotnet 9 or 10 releases? Access to stack-trace could be very useful in UI libraries utilizing hot-reload capability, and providing a mapping from visual representation to code declaration. I would like to use it in the upcoming version of the QuestPDF Companion application (click on any location in the PDF document to be redirect to corresponding code responsible for that content). Dotnet watch is a good workaround but it degrades development experience.