Browse Source

Merge branch 'master' into window-ownership

pull/3833/head
danwalmsley 6 years ago
committed by GitHub
parent
commit
70c76e7d9b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/Avalonia.Controls/Platform/IWindowBaseImpl.cs
  2. 2
      src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs
  3. 15
      src/Avalonia.Controls/Primitives/PopupRoot.cs
  4. 3
      src/Avalonia.Controls/TopLevel.cs
  5. 10
      src/Avalonia.Controls/Window.cs
  6. 2
      src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs
  7. 2
      src/Avalonia.DesignerSupport/Remote/Stubs.cs
  8. 5
      src/Avalonia.Layout/ILayoutRoot.cs
  9. 2
      src/Avalonia.Native/WindowImplBase.cs
  10. 128
      src/Avalonia.Visuals/Media/Color.cs
  11. 2
      src/Avalonia.X11/X11Window.cs
  12. 26
      src/Windows/Avalonia.Win32/PopupImpl.cs
  13. 2
      src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs
  14. 14
      src/Windows/Avalonia.Win32/WindowImpl.cs
  15. 20
      tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs
  16. 15
      tests/Avalonia.Controls.UnitTests/WindowTests.cs
  17. 2
      tests/Avalonia.UnitTests/MockWindowingPlatform.cs
  18. 112
      tests/Avalonia.Visuals.UnitTests/Media/ColorTests.cs

5
src/Avalonia.Controls/Platform/IWindowBaseImpl.cs

@ -1,5 +1,4 @@
using System;
using Avalonia.Controls;
namespace Avalonia.Platform
{
@ -46,9 +45,9 @@ namespace Avalonia.Platform
IPlatformHandle Handle { get; }
/// <summary>
/// Gets the maximum size of a window on the system.
/// Gets a maximum client size hint for an auto-sizing window, in device-independent pixels.
/// </summary>
Size MaxClientSize { get; }
Size MaxAutoSizeHint { get; }
/// <summary>
/// Sets whether this window appears on top of all other windows

2
src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs

@ -113,7 +113,7 @@ namespace Avalonia.Controls.Presenters
{
var scrollable = (ILogicalScrollable)Owner;
var visualRoot = Owner.GetVisualRoot();
var maxAvailableSize = (visualRoot as WindowBase)?.PlatformImpl?.MaxClientSize
var maxAvailableSize = (visualRoot as WindowBase)?.PlatformImpl?.MaxAutoSizeHint
?? (visualRoot as TopLevel)?.ClientSize;
// If infinity is passed as the available size and we're virtualized then we need to

15
src/Avalonia.Controls/Primitives/PopupRoot.cs

@ -121,7 +121,20 @@ namespace Avalonia.Controls.Primitives
protected override Size MeasureOverride(Size availableSize)
{
var measured = base.MeasureOverride(availableSize);
var maxAutoSize = PlatformImpl?.MaxAutoSizeHint ?? Size.Infinity;
var constraint = availableSize;
if (double.IsInfinity(constraint.Width))
{
constraint = constraint.WithWidth(maxAutoSize.Width);
}
if (double.IsInfinity(constraint.Height))
{
constraint = constraint.WithHeight(maxAutoSize.Height);
}
var measured = base.MeasureOverride(constraint);
var width = measured.Width;
var height = measured.Height;
var widthCache = Width;

3
src/Avalonia.Controls/TopLevel.cs

@ -276,9 +276,6 @@ namespace Avalonia.Controls
set { SetValue(AccessText.ShowAccessKeyProperty, value); }
}
/// <inheritdoc/>
Size ILayoutRoot.MaxClientSize => Size.Infinity;
/// <inheritdoc/>
double ILayoutRoot.LayoutScaling => PlatformImpl?.Scaling ?? 1;

10
src/Avalonia.Controls/Window.cs

@ -188,7 +188,7 @@ namespace Avalonia.Controls
impl.Closing = HandleClosing;
impl.GotInputWhenDisabled = OnGotInputWhenDisabled;
impl.WindowStateChanged = HandleWindowStateChanged;
_maxPlatformClientSize = PlatformImpl?.MaxClientSize ?? default(Size);
_maxPlatformClientSize = PlatformImpl?.MaxAutoSizeHint ?? default(Size);
this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => PlatformImpl?.Resize(x));
PlatformImpl?.ShowTaskbarIcon(ShowInTaskbar);
@ -318,9 +318,6 @@ namespace Avalonia.Controls
/// </summary>
public void BeginResizeDrag(WindowEdge edge, PointerPressedEventArgs e) => PlatformImpl?.BeginResizeDrag(edge, e);
/// <inheritdoc/>
Size ILayoutRoot.MaxClientSize => _maxPlatformClientSize;
/// <inheritdoc/>
Type IStyleable.StyleKey => typeof(Window);
@ -722,15 +719,16 @@ namespace Avalonia.Controls
var sizeToContent = SizeToContent;
var clientSize = ClientSize;
var constraint = clientSize;
var maxAutoSize = PlatformImpl?.MaxAutoSizeHint ?? Size.Infinity;
if (sizeToContent.HasFlagCustom(SizeToContent.Width))
{
constraint = constraint.WithWidth(double.PositiveInfinity);
constraint = constraint.WithWidth(maxAutoSize.Width);
}
if (sizeToContent.HasFlagCustom(SizeToContent.Height))
{
constraint = constraint.WithHeight(double.PositiveInfinity);
constraint = constraint.WithHeight(maxAutoSize.Height);
}
var result = base.MeasureOverride(constraint);

2
src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs

@ -44,7 +44,7 @@ namespace Avalonia.DesignerSupport.Remote
public IPlatformHandle Handle { get; }
public WindowState WindowState { get; set; }
public Action<WindowState> WindowStateChanged { get; set; }
public Size MaxClientSize { get; } = new Size(4096, 4096);
public Size MaxAutoSizeHint { get; } = new Size(4096, 4096);
public event Action LostFocus
{
add {}

2
src/Avalonia.DesignerSupport/Remote/Stubs.cs

@ -19,7 +19,7 @@ namespace Avalonia.DesignerSupport.Remote
public Action Deactivated { get; set; }
public Action Activated { get; set; }
public IPlatformHandle Handle { get; }
public Size MaxClientSize { get; }
public Size MaxAutoSizeHint { get; }
public Size ClientSize { get; }
public double Scaling { get; } = 1.0;
public IEnumerable<object> Surfaces { get; }

5
src/Avalonia.Layout/ILayoutRoot.cs

@ -10,11 +10,6 @@ namespace Avalonia.Layout
/// </summary>
Size ClientSize { get; }
/// <summary>
/// The maximum client size available.
/// </summary>
Size MaxClientSize { get; }
/// <summary>
/// The scaling factor to use in layout.
/// </summary>

2
src/Avalonia.Native/WindowImplBase.cs

@ -336,7 +336,7 @@ namespace Avalonia.Native
_native.BeginMoveDrag();
}
public Size MaxClientSize => Screen.AllScreens.Select(s => s.Bounds.Size.ToSize(s.PixelDensity))
public Size MaxAutoSizeHint => Screen.AllScreens.Select(s => s.Bounds.Size.ToSize(s.PixelDensity))
.OrderByDescending(x => x.Width + x.Height).FirstOrDefault();
public void SetTopmost(bool value)

128
src/Avalonia.Visuals/Media/Color.cs

@ -89,33 +89,64 @@ namespace Avalonia.Media
/// <returns>The <see cref="Color"/>.</returns>
public static Color Parse(string s)
{
if (s == null) throw new ArgumentNullException(nameof(s));
if (s.Length == 0) throw new FormatException();
if (TryParse(s, out Color color))
{
return color;
}
if (s[0] == '#')
throw new FormatException($"Invalid color string: '{s}'.");
}
/// <summary>
/// Parses a color string.
/// </summary>
/// <param name="s">The color string.</param>
/// <returns>The <see cref="Color"/>.</returns>
public static Color Parse(ReadOnlySpan<char> s)
{
if (TryParse(s, out Color color))
{
var or = 0u;
return color;
}
if (s.Length == 7)
{
or = 0xff000000;
}
else if (s.Length != 9)
{
throw new FormatException($"Invalid color string: '{s}'.");
}
throw new FormatException($"Invalid color string: '{s.ToString()}'.");
}
return FromUInt32(uint.Parse(s.Substring(1), NumberStyles.HexNumber, CultureInfo.InvariantCulture) | or);
/// <summary>
/// Parses a color string.
/// </summary>
/// <param name="s">The color string.</param>
/// <param name="color">The parsed color</param>
/// <returns>The status of the operation.</returns>
public static bool TryParse(string s, out Color color)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}
if (s.Length == 0)
{
throw new FormatException();
}
if (s[0] == '#' && TryParseInternal(s.AsSpan(), out color))
{
return true;
}
var knownColor = KnownColors.GetKnownColor(s);
if (knownColor != KnownColor.None)
{
return knownColor.ToColor();
color = knownColor.ToColor();
return true;
}
throw new FormatException($"Invalid color string: '{s}'.");
color = default;
return false;
}
/// <summary>
@ -126,40 +157,79 @@ namespace Avalonia.Media
/// <returns>The status of the operation.</returns>
public static bool TryParse(ReadOnlySpan<char> s, out Color color)
{
color = default;
if (s == null)
return false;
if (s.Length == 0)
{
color = default;
return false;
}
if (s[0] == '#')
{
var or = 0u;
return TryParseInternal(s, out color);
}
var knownColor = KnownColors.GetKnownColor(s.ToString());
if (knownColor != KnownColor.None)
{
color = knownColor.ToColor();
return true;
}
color = default;
return false;
}
private static bool TryParseInternal(ReadOnlySpan<char> s, out Color color)
{
static bool TryParseCore(ReadOnlySpan<char> input, ref Color color)
{
var alphaComponent = 0u;
if (s.Length == 7)
if (input.Length == 6)
{
or = 0xff000000;
alphaComponent = 0xff000000;
}
else if (s.Length != 9)
else if (input.Length != 8)
{
return false;
}
if(!uint.TryParse(s.Slice(1).ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var parsed))
// TODO: (netstandard 2.1) Can use allocation free parsing.
if (!uint.TryParse(input.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture,
out var parsed))
{
return false;
color = FromUInt32(parsed| or);
}
color = FromUInt32(parsed | alphaComponent);
return true;
}
var knownColor = KnownColors.GetKnownColor(s.ToString());
color = default;
if (knownColor != KnownColor.None)
ReadOnlySpan<char> input = s.Slice(1);
// Handle shorthand cases like #FFF (RGB) or #FFFF (ARGB).
if (input.Length == 3 || input.Length == 4)
{
color = knownColor.ToColor();
return true;
var extendedLength = 2 * input.Length;
Span<char> extended = stackalloc char[extendedLength];
for (int i = 0; i < input.Length; i++)
{
extended[2 * i + 0] = input[i];
extended[2 * i + 1] = input[i];
}
return TryParseCore(extended, ref color);
}
return false;
return TryParseCore(input, ref color);
}
/// <summary>

2
src/Avalonia.X11/X11Window.cs

@ -922,7 +922,7 @@ namespace Avalonia.X11
public IScreenImpl Screen => _platform.Screens;
public Size MaxClientSize => _platform.X11Screens.Screens.Select(s => s.Bounds.Size.ToSize(s.PixelDensity))
public Size MaxAutoSizeHint => _platform.X11Screens.Screens.Select(s => s.Bounds.Size.ToSize(s.PixelDensity))
.OrderByDescending(x => x.Width + x.Height).FirstOrDefault();

26
src/Windows/Avalonia.Win32/PopupImpl.cs

@ -8,12 +8,35 @@ namespace Avalonia.Win32
class PopupImpl : WindowImpl, IPopupImpl
{
private bool _dropShadowHint = true;
private Size? _maxAutoSize;
public override void Show()
{
UnmanagedMethods.ShowWindow(Handle.Handle, UnmanagedMethods.ShowWindowCommand.ShowNoActivate);
}
public override Size MaxAutoSizeHint
{
get
{
if (_maxAutoSize is null)
{
var monitor = UnmanagedMethods.MonitorFromWindow(
Hwnd,
UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST);
if (monitor != IntPtr.Zero)
{
var info = UnmanagedMethods.MONITORINFO.Create();
UnmanagedMethods.GetMonitorInfo(monitor, ref info);
_maxAutoSize = info.rcWork.ToPixelRect().ToRect(Scaling).Size;
}
}
return _maxAutoSize ?? Size.Infinity;
}
}
protected override IntPtr CreateWindowOverride(ushort atom)
{
UnmanagedMethods.WindowStyles style =
@ -47,6 +70,9 @@ namespace Avalonia.Win32
{
switch ((UnmanagedMethods.WindowsMessage)msg)
{
case UnmanagedMethods.WindowsMessage.WM_DISPLAYCHANGE:
_maxAutoSize = null;
goto default;
case UnmanagedMethods.WindowsMessage.WM_MOUSEACTIVATE:
return (IntPtr)UnmanagedMethods.MouseActivate.MA_NOACTIVATE;
default:

2
src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs

@ -393,6 +393,8 @@ namespace Avalonia.Win32
case WindowsMessage.WM_GETMINMAXINFO:
{
MINMAXINFO mmi = Marshal.PtrToStructure<MINMAXINFO>(lParam);
_maxTrackSize = mmi.ptMaxTrackSize;
if (_minSize.Width > 0)
{

14
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -66,6 +66,7 @@ namespace Avalonia.Win32
private OleDropTarget _dropTarget;
private Size _minSize;
private Size _maxSize;
private POINT _maxTrackSize;
private WindowImpl _parent;
public WindowImpl()
@ -168,16 +169,7 @@ namespace Avalonia.Win32
public IPlatformHandle Handle { get; private set; }
public Size MaxClientSize
{
get
{
return (new Size(
GetSystemMetrics(SystemMetric.SM_CXMAXTRACK),
GetSystemMetrics(SystemMetric.SM_CYMAXTRACK))
- BorderThickness) / Scaling;
}
}
public virtual Size MaxAutoSizeHint => new Size(_maxTrackSize.X / Scaling, _maxTrackSize.Y / Scaling);
public IMouseDevice MouseDevice => _mouseDevice;
@ -211,6 +203,8 @@ namespace Avalonia.Win32
public WindowTransparencyLevel TransparencyLevel { get; private set; }
protected IntPtr Hwnd => _hwnd;
public void SetTransparencyLevelHint (WindowTransparencyLevel transparencyLevel)
{
TransparencyLevel = EnableBlur(transparencyLevel);

20
tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
@ -181,18 +182,21 @@ namespace Avalonia.Controls.UnitTests.Primitives
}
[Fact]
public void Child_Should_Be_Measured_With_Infinity()
public void Child_Should_Be_Measured_With_MaxAutoSizeHint()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var child = new ChildControl();
var window = new Window();
var target = CreateTarget(window);
var popupImpl = MockWindowingPlatform.CreatePopupMock(window.PlatformImpl);
popupImpl.Setup(x => x.MaxAutoSizeHint).Returns(new Size(1200, 1000));
var target = CreateTarget(window, popupImpl.Object);
target.Content = child;
target.Show();
Assert.Equal(Size.Infinity, child.MeasureSize);
Assert.Equal(1, child.MeasureSizes.Count);
Assert.Equal(new Size(1200, 1000), child.MeasureSizes[0]);
}
}
@ -210,7 +214,8 @@ namespace Avalonia.Controls.UnitTests.Primitives
target.Content = child;
target.Show();
Assert.Equal(new Size(500, 600), child.MeasureSize);
Assert.Equal(1, child.MeasureSizes.Count);
Assert.Equal(new Size(500, 600), child.MeasureSizes[0]);
}
}
@ -228,7 +233,8 @@ namespace Avalonia.Controls.UnitTests.Primitives
target.Content = child;
target.Show();
Assert.Equal(new Size(500, 600), child.MeasureSize);
Assert.Equal(1, child.MeasureSizes.Count);
Assert.Equal(new Size(500, 600), child.MeasureSizes[0]);
}
}
@ -365,11 +371,11 @@ namespace Avalonia.Controls.UnitTests.Primitives
private class ChildControl : Control
{
public Size MeasureSize { get; private set; }
public List<Size> MeasureSizes { get; } = new List<Size>();
protected override Size MeasureOverride(Size availableSize)
{
MeasureSize = availableSize;
MeasureSizes.Add(availableSize);
return base.MeasureOverride(availableSize);
}
}

15
tests/Avalonia.Controls.UnitTests/WindowTests.cs

@ -297,12 +297,12 @@ namespace Avalonia.Controls.UnitTests
{
var parentWindowImpl = MockWindowingPlatform.CreateWindowMock();
parentWindowImpl.Setup(x => x.ClientSize).Returns(new Size(800, 480));
parentWindowImpl.Setup(x => x.MaxClientSize).Returns(new Size(1920, 1080));
parentWindowImpl.Setup(x => x.MaxAutoSizeHint).Returns(new Size(1920, 1080));
parentWindowImpl.Setup(x => x.Scaling).Returns(1);
var windowImpl = MockWindowingPlatform.CreateWindowMock();
windowImpl.Setup(x => x.ClientSize).Returns(new Size(320, 200));
windowImpl.Setup(x => x.MaxClientSize).Returns(new Size(1920, 1080));
windowImpl.Setup(x => x.MaxAutoSizeHint).Returns(new Size(1920, 1080));
windowImpl.Setup(x => x.Scaling).Returns(1);
var parentWindowServices = TestServices.StyledWindow.With(
@ -381,12 +381,15 @@ namespace Avalonia.Controls.UnitTests
}
[Fact]
public void Child_Should_Be_Measured_With_Infinity_If_SizeToContent_Is_WidthAndHeight()
public void Child_Should_Be_Measured_With_MaxAutoSizeHint_If_SizeToContent_Is_WidthAndHeight()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var windowImpl = MockWindowingPlatform.CreateWindowMock();
windowImpl.Setup(x => x.MaxAutoSizeHint).Returns(new Size(1200, 1000));
var child = new ChildControl();
var target = new Window
var target = new Window(windowImpl.Object)
{
Width = 100,
Height = 50,
@ -394,10 +397,10 @@ namespace Avalonia.Controls.UnitTests
Content = child
};
Show(target);
target.Show();
Assert.Equal(1, child.MeasureSizes.Count);
Assert.Equal(Size.Infinity, child.MeasureSizes[0]);
Assert.Equal(new Size(1200, 1000), child.MeasureSizes[0]);
}
}

2
tests/Avalonia.UnitTests/MockWindowingPlatform.cs

@ -28,6 +28,7 @@ namespace Avalonia.UnitTests
windowImpl.SetupAllProperties();
windowImpl.Setup(x => x.ClientSize).Returns(() => clientSize);
windowImpl.Setup(x => x.MaxAutoSizeHint).Returns(s_screenSize);
windowImpl.Setup(x => x.Scaling).Returns(1);
windowImpl.Setup(x => x.Screen).Returns(CreateScreenMock().Object);
windowImpl.Setup(x => x.Position).Returns(() => position);
@ -79,6 +80,7 @@ namespace Avalonia.UnitTests
popupImpl.SetupAllProperties();
popupImpl.Setup(x => x.ClientSize).Returns(() => clientSize);
popupImpl.Setup(x => x.MaxAutoSizeHint).Returns(s_screenSize);
popupImpl.Setup(x => x.Scaling).Returns(1);
popupImpl.Setup(x => x.PopupPositioner).Returns(positioner);

112
tests/Avalonia.Visuals.UnitTests/Media/ColorTests.cs

@ -17,6 +17,41 @@ namespace Avalonia.Visuals.UnitTests.Media
Assert.Equal(0xff, result.A);
}
[Fact]
public void Try_Parse_Parses_RGB_Hash_Color()
{
var success = Color.TryParse("#ff8844", out Color result);
Assert.True(success);
Assert.Equal(0xff, result.R);
Assert.Equal(0x88, result.G);
Assert.Equal(0x44, result.B);
Assert.Equal(0xff, result.A);
}
[Fact]
public void Parse_Parses_RGB_Hash_Shorthand_Color()
{
var result = Color.Parse("#f84");
Assert.Equal(0xff, result.R);
Assert.Equal(0x88, result.G);
Assert.Equal(0x44, result.B);
Assert.Equal(0xff, result.A);
}
[Fact]
public void Try_Parse_Parses_RGB_Hash_Shorthand_Color()
{
var success = Color.TryParse("#f84", out Color result);
Assert.True(success);
Assert.Equal(0xff, result.R);
Assert.Equal(0x88, result.G);
Assert.Equal(0x44, result.B);
Assert.Equal(0xff, result.A);
}
[Fact]
public void Parse_Parses_ARGB_Hash_Color()
{
@ -28,6 +63,41 @@ namespace Avalonia.Visuals.UnitTests.Media
Assert.Equal(0x40, result.A);
}
[Fact]
public void Try_Parse_Parses_ARGB_Hash_Color()
{
var success = Color.TryParse("#40ff8844", out Color result);
Assert.True(success);
Assert.Equal(0xff, result.R);
Assert.Equal(0x88, result.G);
Assert.Equal(0x44, result.B);
Assert.Equal(0x40, result.A);
}
[Fact]
public void Parse_Parses_ARGB_Hash_Shorthand_Color()
{
var result = Color.Parse("#4f84");
Assert.Equal(0xff, result.R);
Assert.Equal(0x88, result.G);
Assert.Equal(0x44, result.B);
Assert.Equal(0x44, result.A);
}
[Fact]
public void Try_Parse_Parses_ARGB_Hash_Shorthand_Color()
{
var success = Color.TryParse("#4f84", out Color result);
Assert.True(success);
Assert.Equal(0xff, result.R);
Assert.Equal(0x88, result.G);
Assert.Equal(0x44, result.B);
Assert.Equal(0x44, result.A);
}
[Fact]
public void Parse_Parses_Named_Color_Lowercase()
{
@ -39,6 +109,18 @@ namespace Avalonia.Visuals.UnitTests.Media
Assert.Equal(0xff, result.A);
}
[Fact]
public void TryParse_Parses_Named_Color_Lowercase()
{
var success = Color.TryParse("red", out Color result);
Assert.True(success);
Assert.Equal(0xff, result.R);
Assert.Equal(0x00, result.G);
Assert.Equal(0x00, result.B);
Assert.Equal(0xff, result.A);
}
[Fact]
public void Parse_Parses_Named_Color_Uppercase()
{
@ -50,22 +132,52 @@ namespace Avalonia.Visuals.UnitTests.Media
Assert.Equal(0xff, result.A);
}
[Fact]
public void TryParse_Parses_Named_Color_Uppercase()
{
var success = Color.TryParse("RED", out Color result);
Assert.True(success);
Assert.Equal(0xff, result.R);
Assert.Equal(0x00, result.G);
Assert.Equal(0x00, result.B);
Assert.Equal(0xff, result.A);
}
[Fact]
public void Parse_Hex_Value_Doesnt_Accept_Too_Few_Chars()
{
Assert.Throws<FormatException>(() => Color.Parse("#ff"));
}
[Fact]
public void TryParse_Hex_Value_Doesnt_Accept_Too_Few_Chars()
{
Assert.False(Color.TryParse("#ff", out _));
}
[Fact]
public void Parse_Hex_Value_Doesnt_Accept_Too_Many_Chars()
{
Assert.Throws<FormatException>(() => Color.Parse("#ff5555555"));
}
[Fact]
public void TryParse_Hex_Value_Doesnt_Accept_Too_Many_Chars()
{
Assert.False(Color.TryParse("#ff5555555", out _));
}
[Fact]
public void Parse_Hex_Value_Doesnt_Accept_Invalid_Number()
{
Assert.Throws<FormatException>(() => Color.Parse("#ff808g80"));
}
[Fact]
public void TryParse_Hex_Value_Doesnt_Accept_Invalid_Number()
{
Assert.False(Color.TryParse("#ff808g80", out _));
}
}
}

Loading…
Cancel
Save