Skip to content

[mbr] hot reload doesn't work on lambda bodies #50249

Closed

Description

@SteveSandersonMS

Description

The hot reload feature seems to work a lot better on Index.razor than on certain other files. I'm not sure why the behavior differs.

Steps:

  • Use latest preview 3 SDK
  • dotnet new blazorwasm -o MyApp
  • cd MyApp
  • dotnet watch
  • When the app is running, modify some text in Pages/Index.razor - see it appears correctly in the browser
  • Now try a similar edit inside Shared/NavMenu.razor, for example change the text Home to Home2.
    • Expected: change is applied
    • Actual: runtime crashes

image

Configuration

This is with SDK 6.0.100-preview.3.21173.6, with Microsoft.NETCoreSdk.BundledVersions.props patched to use the runtime version 6.0.0-preview.4.21174.4.

cc @lambdageek

Activity

  1. added
    arch-wasm
    on Mar 25, 2021
  2. ghost added
    untriaged
    on Mar 25, 2021
  3. added this to the 6.0.0 milestone on Mar 25, 2021
  4. SteveSandersonMS commented on Mar 25, 2021

    @SteveSandersonMS
    MemberAuthor

    @lambdageek I've no idea if this is also addressed by #50248 but thought it best to report it rather than waiting to see.

  5. lambdageek commented on Mar 25, 2021

    @lambdageek
    Member

    @SteveSandersonMS doesn't look like it's the same thing.

    @SteveSandersonMS when reporting these, one thing that would be super helpful:

    1. Save the baseline .dll
    2. Open a JS console and put a breakpoint in aspnetcore-browser-refresh.js in the applyBlazorDeltas function inside the foreach.
    3. When it hits the breakpoint, in the console display the values of d.metadataDelta and d.ilDelta and save them. (please make sure that the JS console isn't eliding the middle with "...")
    4. hit Continue in the JS debugger and repeat for any other deltas.
  6. self-assigned this
    on Mar 25, 2021
  7. lambdageek commented on Mar 25, 2021

    @lambdageek
    Member

    The body of the NavLink component is a RenderFragment lambda, and changing "Home" => "Home2" is updating the lambda body. It's emitting new fields and methods on the lambda, which Mono MBR doesn't support yet. (ie this is a rude edit - but we need dotnet/roslyn#49010 in order to signal it)

    (Update, just for my info)
    The decompiled relevant part of NavMenu::BuildRenderTree body before the update is:

    			__builder.OpenComponent<NavLink>(20);
    			__builder.AddAttribute(21, "class", "nav-link");
    			__builder.AddAttribute(22, "href", "");
    			__builder.AddAttribute(23, "Match", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck(NavLinkMatch.All));
    			__builder.AddAttribute(24, "ChildContent", (RenderFragment)delegate(RenderTreeBuilder __builder2)
    			{
    				__builder2.AddMarkupContent(25, "<span class=\"oi oi-home\" aria-hidden=\"true\" b-zgi052wrvj></span> Home\r\n            ");
    			});
    			__builder.CloseComponent();

    Update
    So really this is an issue about supporting updates of lambdas. Which we should do. But we're not there yet

  8. added and removed
    untriaged
    on Mar 25, 2021
  9. changed the title [-]WebAssembly hot reload always fails on certain files[/-] [+][mbr] WebAssembly hot reload always fails on certain files[/+] on Mar 25, 2021
  10. changed the title [-][mbr] WebAssembly hot reload always fails on certain files[/-] [+][mbr] hot reload doesn't work on lambda bodies[/+] on Mar 25, 2021
  11. 2 remaining items

  12. added
    area-EnC-mono
    and removed on Apr 23, 2021
  13. lewing commented on Jul 31, 2021

    @lewing
    Member

    @lambdageek is this still targeting 6.0?

  14. lambdageek commented on Aug 1, 2021

    @lambdageek
    Member

    Emitting new lambdas is going to be 7.

    Updating the bodies of existing lambdas might happen in 6 - there are some circumstances where dotnet watch+Roslyn emit a delta that puts an updated lambda body into a new method where in CI we see Roslyn update an existing lambda body. We should be able to get dotnet watch+Roslyn to update existing lambdas, too.

  15. lambdageek commented on Aug 13, 2021

    @lambdageek
    Member

    Updating of existing lambda bodies that are generated from .razor pages will become supported once dotnet/roslyn#55407 makes it into the dotnet SDK.

    Adding new lambdas will be .net 7

  16. modified the milestones: 6.0.0, 7.0.0 on Aug 13, 2021
  17. ghost added
    in-pr
    on Jan 11, 2022
  18. ghost removed
    in-pr
    on Jan 18, 2022
  19. lambdageek commented on Jan 18, 2022

    @lambdageek
    Member

    Adding new lambdas (either static lambdas that don't capture anything, or new lambdas that capture this when there is already at least one lambda that captures this, or lambdas that capture locals (as long as there's already at least one lambda that captures the same locals) will be supported in the first preview of .NET 7 (Fixed in #63513).

  20. added a commit that references this issue on Jan 20, 2022
  21. added a commit that references this issue on Jan 27, 2022
  22. ghost locked as resolved and limited conversation to collaborators on Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-EnC-mono

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions