Skip to content

Provide full updateTypes to MetadataUpdateHandlers #52937

Open
@jeromelaban

Description

@jeromelaban

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Using Hot Reload should provide the updated types that the HotReload workspace is generating. At present time, the browserlink integration does not fill the updatedTypes parameter properly when deltas are sent.

The aspnetcore-browser-refresh.js contains this:

    let applyError = undefined;
    if (window.Blazor?._internal?.applyHotReload) {
      // Only apply hot reload deltas if Blazor has been initialized.
      // It's possible for Blazor to start after the initial page load, so we don't consider skipping this step
      // to be a failure. These deltas will get applied later, when Blazor completes initialization.
      deltas.forEach(d => {
        try {
          window.Blazor._internal.applyHotReload(d.moduleId, d.metadataDelta, d.ilDelta, d.pdbDelta)
        } catch (error) {
          console.warn(error);
          applyError = error;
        }
      });
    }

And while d.updatedTypes exists, this member is not passed to window.Blazor._internal.applyHotReload:

image

Expected Behavior

updatedTypes should not be empty when a type member is hot reloaded in Visual Studio.

Steps To Reproduce

Add the following to a blazor webassembly app:

   [assembly:MetadataUpdateHandler(typeof(MyHandler))]

    static class MyHandler
    {
        static void ClearCache(Type[]? updatedTypes)
        {
            Console.WriteLine("ClearCache: " + string.Join(",", updatedTypes.Select(t => t.ToString())));

        }
        static void UpdateApplication(Type[]? updatedTypes)
        {
            Console.WriteLine("UpdateApplication: " + string.Join(",", updatedTypes.Select(t => t.ToString())));
        }
    }

Exceptions (if any)

None.

.NET Version

8.0.100

Anything else?

It is likely that such a change will require:

public static void ApplyHotReloadDelta(string moduleIdString, byte[] metadataDelta, byte[] ilDelta, byte[] pdbBytes)

To be updated to use updatedTypes in the same fashion that dotnet/sdk uses it:

https://github.com/dotnet/sdk/blob/50ccc948eb082d316158b709301b28c5e7f60c01/src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L230

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Dev ExperiencePriority:1Work that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-hot-reloadThis issue is related to the Hot Reload feaature

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions