From 1071846d929dc5458fc83756b04c9ac17921eb74 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 8 Nov 2024 16:13:44 -0500 Subject: [PATCH] fix: Make sure if a processor is reported more than once the client handles it properly --- .../RemoteControlClient.Status.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Uno.UI.RemoteControl/RemoteControlClient.Status.cs b/src/Uno.UI.RemoteControl/RemoteControlClient.Status.cs index f7a9dd9543bd..047415e4a9db 100644 --- a/src/Uno.UI.RemoteControl/RemoteControlClient.Status.cs +++ b/src/Uno.UI.RemoteControl/RemoteControlClient.Status.cs @@ -150,7 +150,19 @@ public void ReportServerProcessors(ProcessorsDiscoveryResponse response) static IEnumerable GetMissingServerProcessors(ImmutableHashSet requiredProcessors, ProcessorsDiscoveryResponse response) { - var loaded = response.Processors.ToDictionary(p => p.Type, StringComparer.OrdinalIgnoreCase); + var loaded = response + .Processors + .GroupBy(p => p.Type, StringComparer.OrdinalIgnoreCase) + // If a processors is being loaded multiple times, we prefer to keep the result that has no error. + .Select(g => g + .OrderBy(p => p switch + { + { LoadError: not null } => 0, + { IsLoaded: false } => 1, + _ => 2 + }) + .Last()) + .ToDictionary(p => p.Type, StringComparer.OrdinalIgnoreCase); foreach (var required in requiredProcessors) { if (!loaded.TryGetValue(required.TypeFullName, out var actual))