Browse Source

Throw ObjectDisposedException when PlatformImpl is null in HeadlessExtension (#21276)

bump-diagnosticssupport
Max Katz 5 months ago
committed by GitHub
parent
commit
ea94d81609
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs

8
src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs

@ -153,7 +153,11 @@ public static class HeadlessWindowExtensions
private static IHeadlessWindow GetImpl(this TopLevel topLevel) private static IHeadlessWindow GetImpl(this TopLevel topLevel)
{ {
return topLevel.PlatformImpl as IHeadlessWindow ?? return topLevel.PlatformImpl switch
throw new InvalidOperationException("TopLevel must be a headless window."); {
null => throw new ObjectDisposedException(topLevel.GetType().Name),
IHeadlessWindow headless => headless,
_ => throw new InvalidOperationException("TopLevel must be a headless window.")
};
} }
} }

Loading…
Cancel
Save