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

feat: Add diagnostics indicator for hot-reload #16986

Merged
merged 27 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9b5b00f
fix: Fix possible exception when implementing custom version of HR at…
dr1rrb May 14, 2024
2e26665
test: Test the WekEventManager
dr1rrb May 15, 2024
adc1172
test: Add test for the remove handler while raising
dr1rrb May 15, 2024
fdfe38b
feat: Add DiagnoscticsOverlay utility
dr1rrb Jun 3, 2024
96d8c63
feat: Make VS publish hot-reload events to dev-server
dr1rrb Jun 3, 2024
8d2600b
feat: Instrument dev-server to expose in diagnostics in client
dr1rrb Jun 3, 2024
3d92130
feat: Add disagnostic indocator for hot-reload process
dr1rrb Jun 3, 2024
d1ff74d
chore: Apply code review coments
dr1rrb Jun 4, 2024
caba571
chore: Typos
dr1rrb Jun 4, 2024
f4148e0
chore: Extract RC.Status into dedicted class to improve re-use
dr1rrb Jun 4, 2024
18cf119
feat: Improve HR diag view
dr1rrb Jun 6, 2024
723e48b
fix(dev-server): Improve socket performance
dr1rrb Jun 6, 2024
97d0a1d
chore: Fix UWP build
dr1rrb Jun 6, 2024
7a1f6eb
fix: Fix invalid message in HR indicator
dr1rrb Jun 6, 2024
93f0f32
chore: More build fixes
dr1rrb Jun 6, 2024
47bfa4d
feat(diags): Add ability for a diag view to send notifications
dr1rrb Jun 11, 2024
447c9cc
chore: Improve diag UI
dr1rrb Jun 12, 2024
fb5e56f
chore: Fix UWP build
dr1rrb Jun 14, 2024
937edd7
chore: Add some docs
dr1rrb Jun 14, 2024
154e822
chore: Fix build
dr1rrb Jun 17, 2024
f42c7cc
chore: Remove HR diag from windows head
dr1rrb Jun 18, 2024
cae5518
chore: Fix WinAppSDK build
dr1rrb Jun 18, 2024
93dc4e8
chore: Fix UWP toolkit build
dr1rrb Jun 19, 2024
4be66f4
chore: Fix HR testing failing due to IDE0055 ...
dr1rrb Jun 19, 2024
13acb93
chore: Completely remove diag overlay form UWP since runtime is too o…
dr1rrb Jun 19, 2024
43cae2a
chore: Fix IDE rules in HRApp
dr1rrb Jun 20, 2024
92904f1
test: Fix failing test on CI
dr1rrb Jun 20, 2024
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
2 changes: 1 addition & 1 deletion src/Uno.CrossTargetting.targets
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<_OverrideTargetFramework Condition="$(_OverrideTargetFramework.EndsWith('.0-android'))">$(_OverrideTargetFramework)30.0</_OverrideTargetFramework>

<_overridePackageId>$(CommonOverridePackageId.ToLowerInvariant())</_overridePackageId>
<_overridePackageId Condition="'$(CommonOverridePackageId)'==''">$(AssemblyName.ToLowerVariant())</_overridePackageId>
<_overridePackageId Condition="'$(CommonOverridePackageId)'==''">$(AssemblyName.ToLowerInvariant())</_overridePackageId>
<_overridePackageId Condition="'$(UNO_UWP_BUILD)'=='false'">$(_overridePackageId.Replace('uno.ui','uno.winui'))</_overridePackageId>
<_TargetNugetFolder>$(NuGetPackageRoot)\$(_overridePackageId)\$(UnoNugetOverrideVersion)\lib\$(_OverrideTargetFramework)</_TargetNugetFolder>
<_TargetNugetRefFolder>$(NuGetPackageRoot)\$(_overridePackageId)\$(UnoNugetOverrideVersion)\ref\$(_OverrideTargetFramework)</_TargetNugetRefFolder>
Expand Down
29 changes: 29 additions & 0 deletions src/Uno.Foundation/Diagnostics/DiagnosticViewNotification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#nullable enable
using System;
using System.ComponentModel;
using System.Linq;

namespace Uno.Diagnostics.UI;

/// <summary>
/// A notification sent by a diagnostic view to visually show an important status.
/// </summary>
/// <param name="content">The content of the notification.</param>
/// <param name="duration">Configures the duration to wait before automatically hide the notification.</param>
public class DiagnosticViewNotification(object content, TimeSpan? duration = null)
{
[EditorBrowsable(EditorBrowsableState.Never)] // For XAML only
public DiagnosticViewNotification() : this(default!)
{
}

/// <summary>
/// The content of the notification.
/// </summary>
public object Content { get; set; } = content;

/// <summary>
/// Configures the duration to wait before automatically hide the notification.
/// </summary>
public TimeSpan? Duration { get; set; } = duration;
}
56 changes: 56 additions & 0 deletions src/Uno.Foundation/Diagnostics/DiagnosticViewRegistry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable
using System;
using System.Collections.Immutable;
using System.Linq;

namespace Uno.Diagnostics.UI;

/// <summary>
/// Registry for view that can be displayed by the DiagnosticOverlay.
/// </summary>
internal static class DiagnosticViewRegistry
{
internal static EventHandler<IImmutableList<DiagnosticViewRegistration>>? Added;

private static ImmutableArray<DiagnosticViewRegistration> _registrations = ImmutableArray<DiagnosticViewRegistration>.Empty;

/// <summary>
/// Gets the list of registered diagnostic providers.
/// </summary>
internal static IImmutableList<DiagnosticViewRegistration> Registrations => _registrations;
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Register a global diagnostic view that can be displayed on any window.
/// </summary>
/// <param name="view">A diagnostic view to display.</param>
public static void Register(IDiagnosticView view)
{
ImmutableInterlocked.Update(
ref _registrations,
static (providers, provider) => providers.Add(provider),
new DiagnosticViewRegistration(DiagnosticViewRegistrationMode.One, view));

Added?.Invoke(null, _registrations);
}
}

internal record DiagnosticViewRegistration(DiagnosticViewRegistrationMode Mode, IDiagnosticView View);

internal enum DiagnosticViewRegistrationMode
{
/// <summary>
/// Diagnostic is being rendered as overlay on each window.
/// </summary>
All,

/// <summary>
/// Diagnostic is being display on at least one window.
/// I.e. only the main/first opened but move to the next one if the current window is closed.
/// </summary>
One,

/// <summary>
/// Only registers the diagnostic provider but does not display it.
/// </summary>
OnDemand
}
40 changes: 40 additions & 0 deletions src/Uno.Foundation/Diagnostics/IDiagnosticView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#nullable enable
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Uno.Diagnostics.UI;

/// <summary>
/// A diagnostic entry that can be displayed by the DiagnosticsOverlay.
/// </summary>
public interface IDiagnosticView
{
/// <summary>
/// Identifier of the diagnostic view than can be used to request to show or remove it from a DiagnosticsOverlay.
/// </summary>
string Id { get; }

/// <summary>
/// Friendly name of the diagnostic.
/// </summary>
string Name { get; }

/// <summary>
/// Gets a visual element of the diagnostic, usually a value or an icon.
/// </summary>
/// <param name="context">An update coordinator that can be used to push updates on the preview.</param>
/// <returns>Either a UIElement to be displayed by the diagnostic overlay or a plain object (rendered as text).</returns>
/// <remarks>This is expected to be invoked on the dispatcher used to render the preview.</remarks>
object GetElement(IDiagnosticViewContext context);

/// <summary>
/// Show details of the diagnostic.
/// </summary>
/// <param name="context">An update coordinator that can be used to push updates on the preview.</param>
/// <param name="ct">Token to cancel the async operation.</param>
/// <returns>Either a UIElement to be displayed by the diagnostic overlay, a ContentDialog to show, or a simple object to show in a content dialog.</returns>
/// <remarks>This is expected to be invoked on the dispatcher used to render the preview.</remarks>
ValueTask<object?> GetDetailsAsync(IDiagnosticViewContext context, CancellationToken ct);
}
24 changes: 24 additions & 0 deletions src/Uno.Foundation/Diagnostics/IDiagnosticViewContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#nullable enable
using System;
using System.Linq;

namespace Uno.Diagnostics.UI;

/// <summary>
/// Some information on the context where the diagnostic view is being rendered.
/// </summary>
/// <remarks>This is mainly an abstraction of the dispatcher that ensure to not overload the UI thread for diagnostics.</remarks>
public interface IDiagnosticViewContext
{
/// <summary>
/// Schedule an update of the diagnostic.
/// </summary>
/// <param name="action">Update action.</param>
void Schedule(Action action);

void ScheduleRecurrent(Action action);

void AbortRecurrent(Action action);

void Notify(DiagnosticViewNotification notification);
}
3 changes: 2 additions & 1 deletion src/Uno.UI.RemoteControl.Host/IDEChannel/IdeChannelServer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Uno.UI.RemoteControl.Host.IDEChannel;
using Uno.UI.RemoteControl.Messaging.IdeChannel;
Expand All @@ -22,7 +23,7 @@ public async Task SendToIdeAsync(IdeMessage message)
await Task.Yield();
}

public async Task SendToDevServerAsync(IdeMessageEnvelope message)
public async Task SendToDevServerAsync(IdeMessageEnvelope message, CancellationToken ct)
{
MessageFromIDE?.Invoke(this, IdeMessageSerializer.Deserialize(message));

Expand Down
Loading
Loading