Skip to content

Commit 3ea6071

Browse files
authored
Update HotReloadAgent.cs (#32657)
1 parent 44116a9 commit 3ea6071

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Components/WebAssembly/WebAssembly/src/HotReload/HotReloadAgent.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
// Based on the implementation in https://github.com/raw/dotnet/sdk/f67f46eba6d3bcf2b3054381851a975096652454/src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs
4+
// Based on the implementation in https://github.com/raw/dotnet/sdk/0304792ef1f53d64182bcfed2ea490e40983a5c5/src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs
55

66
using System;
77
using System.Collections.Concurrent;
@@ -15,7 +15,7 @@ internal sealed class HotReloadAgent : IDisposable
1515
{
1616
private readonly Action<string> _log;
1717
private readonly AssemblyLoadEventHandler _assemblyLoad;
18-
private readonly ConcurrentDictionary<Guid, IReadOnlyList<UpdateDelta>> _deltas = new();
18+
private readonly ConcurrentDictionary<Guid, List<UpdateDelta>> _deltas = new();
1919
private readonly ConcurrentDictionary<Assembly, Assembly> _appliedAssemblies = new();
2020
private volatile UpdateHandlerActions? _handlerActions;
2121

@@ -197,6 +197,10 @@ public void ApplyDeltas(IReadOnlyList<UpdateDelta> deltas)
197197
{
198198
System.Reflection.Metadata.AssemblyExtensions.ApplyUpdate(assembly, item.MetadataDelta, item.ILDelta, ReadOnlySpan<byte>.Empty);
199199
}
200+
201+
// Additionally stash the deltas away so it may be applied to assemblies loaded later.
202+
var cachedDeltas = _deltas.GetOrAdd(item.ModuleId, static _ => new());
203+
cachedDeltas.Add(item);
200204
}
201205

202206
handlerActions.ClearCache.ForEach(a => a(updatedTypes));

0 commit comments

Comments
 (0)