Skip to content

Commit

Permalink
fix: Fix the discovered processor list additive
Browse files Browse the repository at this point in the history
(cherry picked from commit be56be4)
  • Loading branch information
dr1rrb authored and mergify[bot] committed Nov 9, 2024
1 parent cd7ea2d commit ec79093
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Uno.UI.RemoteControl.Host/RemoteControlServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal class RemoteControlServer : IRemoteControlServer, IDisposable
private static readonly Dictionary<string, (AssemblyLoadContext Context, int Count)> _loadContexts = new();
private static readonly Dictionary<string, string> _resolveAssemblyLocations = new();
private readonly Dictionary<string, IServerProcessor> _processors = new();
private readonly List<DiscoveredProcessor> _discoveredProcessors = new();
private readonly CancellationTokenSource _ct = new();

private WebSocket? _socket;
Expand Down Expand Up @@ -257,7 +258,6 @@ private async Task ProcessPingFrame(Frame frame)
private async Task ProcessDiscoveryFrame(Frame frame)
{
var assemblies = new List<(string path, System.Reflection.Assembly assembly)>();
var discoveredProcessors = new List<DiscoveredProcessor>();
try
{
var msg = JsonConvert.DeserializeObject<ProcessorsDiscovery>(frame.Content)!;
Expand Down Expand Up @@ -358,12 +358,12 @@ private async Task ProcessDiscoveryFrame(Frame frame)
{
if (ActivatorUtilities.CreateInstance(_serviceProvider, processor.ProcessorType, parameters: new[] { this }) is IServerProcessor serverProcessor)
{
discoveredProcessors.Add(new(asm.path, processor.ProcessorType.FullName!, VersionHelper.GetVersion(processor.ProcessorType), IsLoaded: true));
_discoveredProcessors.Add(new(asm.path, processor.ProcessorType.FullName!, VersionHelper.GetVersion(processor.ProcessorType), IsLoaded: true));
RegisterProcessor(serverProcessor);
}
else
{
discoveredProcessors.Add(new(asm.path, processor.ProcessorType.FullName!, VersionHelper.GetVersion(processor.ProcessorType), IsLoaded: false));
_discoveredProcessors.Add(new(asm.path, processor.ProcessorType.FullName!, VersionHelper.GetVersion(processor.ProcessorType), IsLoaded: false));
if (this.Log().IsEnabled(LogLevel.Debug))
{
this.Log().LogDebug("Failed to create server processor {ProcessorType}", processor.ProcessorType);
Expand All @@ -372,7 +372,7 @@ private async Task ProcessDiscoveryFrame(Frame frame)
}
catch (Exception error)
{
discoveredProcessors.Add(new(asm.path, processor.ProcessorType.FullName!, VersionHelper.GetVersion(processor.ProcessorType), IsLoaded: false, LoadError: error.ToString()));
_discoveredProcessors.Add(new(asm.path, processor.ProcessorType.FullName!, VersionHelper.GetVersion(processor.ProcessorType), IsLoaded: false, LoadError: error.ToString()));
if (this.Log().IsEnabled(LogLevel.Error))
{
this.Log().LogError(error, "Failed to create server processor {ProcessorType}", processor.ProcessorType);
Expand Down Expand Up @@ -404,7 +404,7 @@ private async Task ProcessDiscoveryFrame(Frame frame)
{
await SendFrame(new ProcessorsDiscoveryResponse(
assemblies.Select(asm => asm.path).ToImmutableList(),
discoveredProcessors.ToImmutableList()));
_discoveredProcessors.ToImmutableList()));
}
}

Expand Down

0 comments on commit ec79093

Please sign in to comment.