Skip to content

Commit 44bcbf2

Browse files
authored
Clear RootTypeCache cache on HotReload
1 parent a813ad4 commit 44bcbf2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Components/Shared/src/RootTypeCache.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using System.Collections.Concurrent;
55
using System.Diagnostics.CodeAnalysis;
66
using System.Reflection;
7+
#if COMPONENTS
8+
using Microsoft.AspNetCore.Components.HotReload;
9+
#endif
710

811
#if COMPONENTS
912
namespace Microsoft.AspNetCore.Components.Infrastructure;
@@ -16,6 +19,16 @@ internal sealed class RootTypeCache
1619
{
1720
private readonly ConcurrentDictionary<Key, Type?> _typeToKeyLookUp = new();
1821

22+
#if COMPONENTS
23+
static RootTypeCache()
24+
{
25+
if (HotReloadManager.Default.MetadataUpdateSupported)
26+
{
27+
HotReloadManager.Default.OnDeltaApplied += ClearCache;
28+
}
29+
}
30+
#endif
31+
1932
public Type? GetRootType(string assembly, string type)
2033
{
2134
var key = new Key(assembly, type);

0 commit comments

Comments
 (0)