Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Avoid duplicated logs and prevent error bubbling #18746

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 19 additions & 36 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,71 +442,54 @@ private async Task OnMessageReceivedAsync(object? sender, IdeMessage devServerMe
switch (devServerMessage)
{
case AddMenuItemRequestIdeMessage amir:
await OnAddMenuItemRequestIdeMessageAsync(sender, amir);
await OnAddMenuItemRequestedAsync(sender, amir);
break;
case ForceHotReloadIdeMessage fhr:
await OnForceHotReloadRequestedAsync(sender, fhr);
break;
case NotificationRequestIdeMessage nr:
await NotificationRequestIdeMessageAsync(sender, nr);
await OnNotificationRequestedAsync(sender, nr);
break;
default:
_debugAction?.Invoke($"Unknown message type {devServerMessage?.GetType()} from DevServer");
break;
}
}
catch (Exception e) when (_ideChannelClient is not null)
catch (Exception e)
{
_debugAction?.Invoke($"Failed to handle IdeMessage with message {e.Message}");
throw;
}
}

private async Task NotificationRequestIdeMessageAsync(object? sender, NotificationRequestIdeMessage message)
private async Task OnNotificationRequestedAsync(object? sender, NotificationRequestIdeMessage message)
{
try
{
await _asyncPackage.JoinableTaskFactory.SwitchToMainThreadAsync();
await _asyncPackage.JoinableTaskFactory.SwitchToMainThreadAsync();

if (await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell &&
await _asyncPackage.GetServiceAsync(typeof(SVsInfoBarUIFactory)) is IVsInfoBarUIFactory infoBarFactory)
{
await CreateInfoBarAsync(message, shell, infoBarFactory);
}
}
catch (Exception e) when (_ideChannelClient is not null)
if (await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell &&
await _asyncPackage.GetServiceAsync(typeof(SVsInfoBarUIFactory)) is IVsInfoBarUIFactory infoBarFactory)
{
_debugAction?.Invoke($"Failed to handle InfoBar Notification Requested with message {e.Message}");
throw;
await CreateInfoBarAsync(message, shell, infoBarFactory);
}
}

private async Task OnAddMenuItemRequestIdeMessageAsync(object? sender, AddMenuItemRequestIdeMessage cr)
private async Task OnAddMenuItemRequestedAsync(object? sender, AddMenuItemRequestIdeMessage cr)
{
try
if (_ideChannelClient == null)
{
if (_ideChannelClient == null)
{
return;
}
return;
}

if (_unoMenuCommand is not null)
{
//ignore when duplicated
if (!_unoMenuCommand.CommandList.Contains(cr))
{
_unoMenuCommand.CommandList.Add(cr);
}
}
else
if (_unoMenuCommand is not null)
{
//ignore when duplicated
if (!_unoMenuCommand.CommandList.Contains(cr))
{
_unoMenuCommand = await UnoMenuCommand.InitializeAsync(_asyncPackage, _ideChannelClient, cr);
_unoMenuCommand.CommandList.Add(cr);
}
}
catch (Exception e)
else
{
_debugAction?.Invoke($"Using AddMenuItem Ide Message Requested fail {e.Message}");
throw;
_unoMenuCommand = await UnoMenuCommand.InitializeAsync(_asyncPackage, _ideChannelClient, cr);
}
}

Expand Down
Loading