Skip to content

Commit 7afb501

Browse files
Copilotrabbitism
andauthored
Add Debug.Assert for missing OverlayDialogHost with setup guidance (#863)
* Initial plan * Add Debug.Assert when OverlayDialogHost is not found with helpful setup instructions Co-authored-by: rabbitism <14807942+rabbitism@users.noreply.github.com> * fix: improve debug assertion message for OverlayDialogHost setup instructions --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rabbitism <14807942+rabbitism@users.noreply.github.com> Co-authored-by: Dong Bin <popmessiah@hotmail.com>
1 parent 77a3553 commit 7afb501

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/Ursa/Controls/OverlayShared/OverlayDialogManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ public static void UnregisterHost(string? id, int? hash)
2323
public static OverlayDialogHost? GetHost(string? id, int? hash)
2424
{
2525
HostKey? key = hash is null ? Hosts.Keys.Where(k => k.Id == id).ToArray().FirstOrDefault() : Hosts.Keys.FirstOrDefault(k => k.Id == id && k.Hash == hash);
26-
if (key is null) return null;
26+
if (key is null)
27+
{
28+
Debug.Assert(false,
29+
"OverlayDialogHost not found. Please ensure the host is properly set up with one of below method:\n" +
30+
"1. Use UrsaWindow or UrsaView which includes a default OverlayDialogHost in their control templates, or\n" +
31+
"2. Add an OverlayDialogHost control with a HostId property to your view.\n" +
32+
"For more information, see: https://docs.irihi.tech/ursa/docs/advanced/dialog-and-drawer/overlay-dialoghost");
33+
return null;
34+
}
2735
return Hosts.TryGetValue(key.Value, out var host) ? host : null;
2836
}
2937
}

0 commit comments

Comments
 (0)