Skip to content

Commit 70a7fc7

Browse files
committed
chore: Don't skip elements without handlers
1 parent 1daaa51 commit 70a7fc7

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ select handler.Value
190190
// For instance, a DataTemplate in a resource dictionary may mark the type as updated in `updatedTypes`
191191
// but it will not be considered as a new type even if "CreateNewOnMetadataUpdate" was set.
192192

193-
return (fe, ImmutableArray<ElementUpdateHandlerActions>.Empty, liveType);
193+
return (fe, [], liveType);
194194
}
195195
else
196196
{
197-
return !handlers.IsDefaultOrEmpty || mappedType is not null
197+
return (!handlers.IsDefaultOrEmpty || mappedType is not null)
198198
? (fe, handlers, mappedType)
199-
: default;
199+
: (null, [], null);
200200
}
201201
},
202202
parentKey: default);
@@ -208,7 +208,7 @@ select handler.Value
208208
// or replace the element with a new one
209209
foreach (var (element, elementHandlers, elementMappedType) in instancesToUpdate)
210210
{
211-
if (elementHandlers.IsDefaultOrEmpty)
211+
if (element is null)
212212
{
213213
continue;
214214
}
@@ -218,16 +218,16 @@ select handler.Value
218218
foreach (var elementHandler in elementHandlers)
219219
{
220220
elementHandler?.ElementUpdate(element, updatedTypes);
221+
}
221222

222-
if (elementMappedType is not null)
223+
if (elementMappedType is not null)
224+
{
225+
if (_log.IsEnabled(LogLevel.Trace))
223226
{
224-
if (_log.IsEnabled(LogLevel.Trace))
225-
{
226-
_log.Error($"Updating element [{element}] to [{elementMappedType}]");
227-
}
228-
229-
ReplaceViewInstance(element, elementMappedType, elementHandler);
227+
_log.Error($"Updating element [{element}] to [{elementMappedType}]");
230228
}
229+
230+
ReplaceViewInstance(element, elementMappedType, elementHandlers, updatedTypes);
231231
}
232232
}
233233

@@ -413,7 +413,7 @@ private static void UpdateResourceDictionaries(List<Uri> updatedDictionaries, Re
413413
}
414414
#endif
415415

416-
private static void ReplaceViewInstance(UIElement instance, Type replacementType, ElementUpdateAgent.ElementUpdateHandlerActions? handler = default, Type[]? updatedTypes = default)
416+
private static void ReplaceViewInstance(UIElement instance, Type replacementType, in ImmutableArray<ElementUpdateHandlerActions> handlers, Type[] updatedTypes)
417417
{
418418
if (replacementType.GetConstructor(Array.Empty<Type>()) is { } creator)
419419
{
@@ -434,11 +434,17 @@ private static void ReplaceViewInstance(UIElement instance, Type replacementType
434434
oldStore.ClonePropertiesToAnotherStoreForHotReload(newStore);
435435
#endif
436436

437-
handler?.BeforeElementReplaced(instanceFE, newInstanceFE, updatedTypes);
437+
foreach (var handler in handlers)
438+
{
439+
handler.BeforeElementReplaced(instanceFE, newInstanceFE, updatedTypes);
440+
}
438441

439442
SwapViews(instanceFE, newInstanceFE);
440443

441-
handler?.AfterElementReplaced(instanceFE, newInstanceFE, updatedTypes);
444+
foreach (var handler in handlers)
445+
{
446+
handler.AfterElementReplaced(instanceFE, newInstanceFE, updatedTypes);
447+
}
442448
}
443449
}
444450
else

0 commit comments

Comments
 (0)