diff --git a/src/Components/WebAssembly/WebAssembly/src/HotReload/HotReloadAgent.cs b/src/Components/WebAssembly/WebAssembly/src/HotReload/HotReloadAgent.cs index de27c58999c0..aac6cfd916a0 100644 --- a/src/Components/WebAssembly/WebAssembly/src/HotReload/HotReloadAgent.cs +++ b/src/Components/WebAssembly/WebAssembly/src/HotReload/HotReloadAgent.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -// Based on the implementation in https://raw.githubusercontent.com/dotnet/sdk/f67f46eba6d3bcf2b3054381851a975096652454/src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs +// Based on the implementation in https://raw.githubusercontent.com/dotnet/sdk/0304792ef1f53d64182bcfed2ea490e40983a5c5/src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs using System; using System.Collections.Concurrent; @@ -15,7 +15,7 @@ internal sealed class HotReloadAgent : IDisposable { private readonly Action _log; private readonly AssemblyLoadEventHandler _assemblyLoad; - private readonly ConcurrentDictionary> _deltas = new(); + private readonly ConcurrentDictionary> _deltas = new(); private readonly ConcurrentDictionary _appliedAssemblies = new(); private volatile UpdateHandlerActions? _handlerActions; @@ -197,6 +197,10 @@ public void ApplyDeltas(IReadOnlyList deltas) { System.Reflection.Metadata.AssemblyExtensions.ApplyUpdate(assembly, item.MetadataDelta, item.ILDelta, ReadOnlySpan.Empty); } + + // Additionally stash the deltas away so it may be applied to assemblies loaded later. + var cachedDeltas = _deltas.GetOrAdd(item.ModuleId, static _ => new()); + cachedDeltas.Add(item); } handlerActions.ClearCache.ForEach(a => a(updatedTypes));