Browse Source
Throw ObjectDisposedException when PlatformImpl is null in HeadlessExtension (#21276)
bump-diagnosticssupport
Max Katz
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
6 additions and
2 deletions
-
src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs
|
|
|
@ -153,7 +153,11 @@ public static class HeadlessWindowExtensions |
|
|
|
|
|
|
|
private static IHeadlessWindow GetImpl(this TopLevel topLevel) |
|
|
|
{ |
|
|
|
return topLevel.PlatformImpl as IHeadlessWindow ?? |
|
|
|
throw new InvalidOperationException("TopLevel must be a headless window."); |
|
|
|
return topLevel.PlatformImpl switch |
|
|
|
{ |
|
|
|
null => throw new ObjectDisposedException(topLevel.GetType().Name), |
|
|
|
IHeadlessWindow headless => headless, |
|
|
|
_ => throw new InvalidOperationException("TopLevel must be a headless window.") |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|