Fixed Diagnostics dependencies in other packages
This commit is contained in:
Родитель
44a0fa0513
Коммит
90c6f40c44
|
@ -6,7 +6,6 @@
|
|||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
@ -605,7 +604,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
if (!Matrix4x4.Decompose(to, out Vector3 toScale, out Quaternion toRotation, out Vector3 toTranslation))
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException("The destination matrix could not be decomposed");
|
||||
ThrowThrowArgumentExceptionForToDecompose();
|
||||
}
|
||||
|
||||
Vector3? fromScale = null;
|
||||
|
@ -616,7 +615,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
if (!Matrix4x4.Decompose(from.GetValueOrDefault(), out Vector3 scale3, out Quaternion rotation4, out Vector3 translation3))
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException("The initial matrix could not be decomposed");
|
||||
ThrowThrowArgumentExceptionForFromDecompose();
|
||||
}
|
||||
|
||||
fromScale = scale3;
|
||||
|
@ -629,6 +628,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Translation(toTranslation, fromTranslation, delay, duration, easingType, easingMode);
|
||||
|
||||
return this;
|
||||
|
||||
static void ThrowThrowArgumentExceptionForToDecompose() => throw new ArgumentException("The destination matrix could not be decomposed");
|
||||
static void ThrowThrowArgumentExceptionForFromDecompose() => throw new ArgumentException("The initial matrix could not be decomposed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -6,7 +6,6 @@ using System;
|
|||
using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Composition;
|
||||
|
@ -161,7 +160,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
easingFunction);
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowInvalidOperationException<CompositionAnimation>("Invalid animation type");
|
||||
throw new InvalidOperationException("Invalid animation type");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -216,7 +215,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
easingFunction);
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowInvalidOperationException<Timeline>("Invalid animation type");
|
||||
throw new InvalidOperationException("Invalid animation type");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
|
@ -231,7 +230,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
}
|
||||
else
|
||||
{
|
||||
return ThrowHelper.ThrowInvalidOperationException<CompositionAnimation>("Invalid animation type");
|
||||
throw new InvalidOperationException("Invalid animation type");
|
||||
}
|
||||
|
||||
animation.Duration = duration;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
|
@ -118,7 +117,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
}
|
||||
else
|
||||
{
|
||||
return ThrowHelper.ThrowInvalidOperationException<Timeline>("Invalid animation type");
|
||||
static Timeline ThrowInvalidOperationException() => throw new InvalidOperationException("Invalid animation type");
|
||||
|
||||
return ThrowInvalidOperationException();
|
||||
}
|
||||
|
||||
animation.BeginTime = delay;
|
||||
|
|
|
@ -6,7 +6,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
@ -111,7 +110,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Axis.X => "AnchorPoint.X",
|
||||
Axis.Y => "AnchorPoint.Y",
|
||||
Axis.Z => "AnchorPoint.Z",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -132,7 +131,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Axis.X => "Translation.X",
|
||||
Axis.Y => "Translation.Y",
|
||||
Axis.Z => "Translation.Z",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -153,7 +152,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Axis.X => "Offset.X",
|
||||
Axis.Y => "Offset.Y",
|
||||
Axis.Z => "Offset.Z",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -174,7 +173,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Axis.X => "Scale.X",
|
||||
Axis.Y => "Scale.Y",
|
||||
Axis.Z => "Scale.Z",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -195,7 +194,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Axis.X => "CenterPoint.X",
|
||||
Axis.Y => "CenterPoint.Y",
|
||||
Axis.Z => "CenterPoint.Z",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -217,7 +216,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Side.Bottom => nameof(InsetClip.BottomInset),
|
||||
Side.Right => nameof(InsetClip.RightInset),
|
||||
Side.Left => nameof(InsetClip.LeftInset),
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid clip side")
|
||||
_ => ThrowArgumentException<string>("Invalid clip side")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -238,7 +237,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
Axis.X => "Size.X",
|
||||
Axis.Y => "Size.Y",
|
||||
Axis.Z => "Size.Z",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -257,7 +256,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
Axis.X => nameof(CompositeTransform.TranslateX),
|
||||
Axis.Y => nameof(CompositeTransform.TranslateY),
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -270,7 +269,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
Axis.X => nameof(CompositeTransform.ScaleX),
|
||||
Axis.Y => nameof(CompositeTransform.ScaleY),
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -283,7 +282,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
Axis.X => nameof(CompositeTransform.CenterX),
|
||||
Axis.Y => nameof(CompositeTransform.CenterY),
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -296,9 +295,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
Axis.X => nameof(FrameworkElement.Width),
|
||||
Axis.Y => nameof(FrameworkElement.Height),
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid axis")
|
||||
_ => ThrowArgumentException<string>("Invalid axis")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/> with a given message.
|
||||
/// </summary>
|
||||
private static T ThrowArgumentException<T>(string message)
|
||||
{
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using static Microsoft.Toolkit.Uwp.UI.Animations.AnimationExtensions;
|
||||
|
||||
|
@ -46,8 +46,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
EasingType.Quintic => new QuinticEase { EasingMode = easingMode },
|
||||
EasingType.Sine => new SineEase { EasingMode = easingMode },
|
||||
|
||||
_ => ThrowHelper.ThrowArgumentException<EasingFunctionBase?>("Invalid easing type")
|
||||
_ => ThrowArgumentException()
|
||||
};
|
||||
|
||||
static EasingFunctionBase ThrowArgumentException() => throw new ArgumentException("Invalid easing type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
@ -66,11 +66,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
visual.StartAnimation($"{nameof(Visual.Offset)}.{targetAxis}", animation);
|
||||
break;
|
||||
default:
|
||||
ThrowHelper.ThrowArgumentException("Invalid target property");
|
||||
ThrowArgumentException();
|
||||
break;
|
||||
}
|
||||
|
||||
return animation;
|
||||
|
||||
static ExpressionAnimation ThrowArgumentException() => throw new ArgumentException("Invalid target property");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.Foundation.Metadata;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
|
@ -52,7 +51,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
[Pure]
|
||||
public static RepeatOption Count(int count)
|
||||
{
|
||||
Guard.IsGreaterThanOrEqualTo(count, 0, nameof(count));
|
||||
if (count < 0)
|
||||
{
|
||||
ThrowArgumentOutOfRangeForCount();
|
||||
}
|
||||
|
||||
return new(count);
|
||||
}
|
||||
|
@ -76,7 +78,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
return Forever;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<RepeatOption>("Invalid input text");
|
||||
return ThrowArgumentExceptionForText();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -109,5 +111,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
|
||||
return (AnimationIterationBehavior.Count, this.value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/> when the constructor is invoked with an incorrect parameter.
|
||||
/// </summary>
|
||||
private static void ThrowArgumentOutOfRangeForCount()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("The parameter \"count\" must be greater than or equal to 0.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/> when the constructor is invoked with an incorrect parameter.
|
||||
/// </summary>
|
||||
private static RepeatOption ThrowArgumentExceptionForText()
|
||||
{
|
||||
throw new ArgumentException("The input text is not valid to parse a new RepeatOption instance. It must be either a natural number or \"Forever\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Animations
|
||||
|
@ -53,7 +53,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
/// <inheritdoc/>
|
||||
public override async Task InvokeAsync(UIElement element, CancellationToken token)
|
||||
{
|
||||
Guard.IsNotNull(Animation, nameof(Animation));
|
||||
if (Animation is null)
|
||||
{
|
||||
ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
await base.InvokeAsync(element, token);
|
||||
|
||||
|
@ -72,6 +75,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
await Animation.StartAsync(token);
|
||||
}
|
||||
|
||||
static void ThrowArgumentNullException() => throw new ArgumentNullException(nameof(Animation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Animations
|
||||
|
@ -53,7 +53,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
/// <inheritdoc/>
|
||||
public override async Task InvokeAsync(UIElement element, CancellationToken token)
|
||||
{
|
||||
Guard.IsNotNull(Animation, nameof(Animation));
|
||||
if (Animation is null)
|
||||
{
|
||||
ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
await base.InvokeAsync(element, token);
|
||||
|
||||
|
@ -69,6 +72,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
Animation.Stop();
|
||||
}
|
||||
|
||||
static void ThrowArgumentNullException() => throw new ArgumentNullException(nameof(Animation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ using System.Diagnostics.Contracts;
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Animations
|
||||
|
@ -218,10 +217,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
|
||||
if (ParentReference?.TryGetTarget(out parent) != true)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The current animation collection isn't bound to a parent UIElement instance.");
|
||||
ThrowInvalidOperationException();
|
||||
}
|
||||
|
||||
return parent!;
|
||||
|
||||
static void ThrowInvalidOperationException() => throw new InvalidOperationException("The current AnimationSet object isn't bound to a parent UIElement instance.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Hosting;
|
||||
|
@ -85,10 +84,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
|
||||
if (ParentReference?.TryGetTarget(out parent) != true)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The current animation collection isn't bound to a parent UIElement instance.");
|
||||
ThrowInvalidOperationException();
|
||||
}
|
||||
|
||||
return parent!;
|
||||
|
||||
static void ThrowInvalidOperationException() => throw new InvalidOperationException("The current ImplicitAnimationSet object isn't bound to a parent UIElement instance.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Animations;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using Windows.UI.Xaml;
|
||||
|
@ -53,7 +53,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
|
|||
/// <inheritdoc/>
|
||||
public object Execute(object sender, object parameter)
|
||||
{
|
||||
Guard.IsNotNull(Animation, nameof(Animation));
|
||||
if (Animation is null)
|
||||
{
|
||||
ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
if (TargetObject is not null)
|
||||
{
|
||||
|
@ -65,6 +68,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
|
|||
}
|
||||
|
||||
return null!;
|
||||
|
||||
static void ThrowArgumentNullException() => throw new ArgumentNullException(nameof(Animation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.UI.Animations;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using Windows.UI.Xaml;
|
||||
|
@ -53,7 +53,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
|
|||
/// <inheritdoc/>
|
||||
public object Execute(object sender, object parameter)
|
||||
{
|
||||
Guard.IsNotNull(Animation, nameof(Animation));
|
||||
if (Animation is null)
|
||||
{
|
||||
ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
if (TargetObject is not null)
|
||||
{
|
||||
|
@ -65,6 +68,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
|
|||
}
|
||||
|
||||
return null!;
|
||||
|
||||
static void ThrowArgumentNullException() => throw new ArgumentNullException(nameof(Animation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,11 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
@ -233,10 +230,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
T child = this.GetTemplateChild(childName) as T;
|
||||
if ((child == null) && isRequired)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(childName);
|
||||
ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
static void ThrowArgumentNullException() => throw new ArgumentNullException(nameof(childName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -5,11 +5,8 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
|
@ -54,9 +51,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
public InterspersedObservableCollection(object itemsSource)
|
||||
{
|
||||
Guard.IsAssignableToType<IList>(itemsSource, nameof(itemsSource));
|
||||
if (!(itemsSource is IList list))
|
||||
{
|
||||
ThrowArgumentException();
|
||||
}
|
||||
|
||||
ItemsSource = itemsSource as IList;
|
||||
ItemsSource = list;
|
||||
|
||||
if (ItemsSource is INotifyCollectionChanged notifier)
|
||||
{
|
||||
|
@ -67,6 +67,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
};
|
||||
notifier.CollectionChanged += weakPropertyChangedListener.OnEvent;
|
||||
}
|
||||
|
||||
static void ThrowArgumentException() => throw new ArgumentNullException("The input items source must be assignable to the System.Collections.IList type.");
|
||||
}
|
||||
|
||||
private void ItemsSource_CollectionChanged(object source, NotifyCollectionChangedEventArgs eventArgs)
|
||||
|
@ -193,8 +195,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private int ToInnerIndex(int outerIndex)
|
||||
{
|
||||
#if DEBUG
|
||||
Guard.IsInRange(outerIndex, 0, Count, nameof(outerIndex));
|
||||
Guard.IsFalse(_interspersedObjects.ContainsKey(outerIndex), nameof(outerIndex)); // We can't map a inserted key to the original collection!
|
||||
if ((uint)outerIndex >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(outerIndex));
|
||||
}
|
||||
|
||||
if (!_interspersedObjects.ContainsKey(outerIndex))
|
||||
{
|
||||
throw new ArgumentException("The outer index can't be inserted as a key to the original collection.");
|
||||
}
|
||||
#endif
|
||||
|
||||
return outerIndex - _interspersedObjects.Keys.Count(key => key.Value <= outerIndex);
|
||||
|
@ -208,7 +217,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private int ToOuterIndex(int innerIndex)
|
||||
{
|
||||
#if DEBUG
|
||||
Guard.IsInRange(innerIndex, 0, ItemsSource.Count, nameof(innerIndex));
|
||||
if ((uint)innerIndex >= ItemsSource.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(innerIndex));
|
||||
}
|
||||
#endif
|
||||
|
||||
var keys = _interspersedObjects.OrderBy(v => v.Key);
|
||||
|
@ -236,7 +248,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private int ToOuterIndexAfterRemoval(int innerIndexToProject)
|
||||
{
|
||||
#if DEBUG
|
||||
Guard.IsInRange(innerIndexToProject, 0, ItemsSource.Count + 1, nameof(innerIndexToProject));
|
||||
if ((uint)innerIndexToProject >= ItemsSource.Count + 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(innerIndexToProject));
|
||||
}
|
||||
#endif
|
||||
|
||||
//// TODO: Deal with bounds (0 / Count)? Or is it the same?
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
|
@ -28,9 +27,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="columns">The number of columns to track.</param>
|
||||
public TakenSpotsReferenceHolder(int rows, int columns)
|
||||
{
|
||||
Guard.IsGreaterThanOrEqualTo(rows, 0, nameof(rows));
|
||||
Guard.IsGreaterThanOrEqualTo(columns, 0, nameof(columns));
|
||||
|
||||
Height = rows;
|
||||
Width = columns;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
|
@ -63,8 +62,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
Orientation.Vertical => new Rect(Position.V, Position.U, Size.V, Size.U),
|
||||
Orientation.Horizontal => new Rect(Position.U, Position.V, Size.U, Size.V),
|
||||
_ => ThrowHelper.ThrowNotSupportedException<Rect>("unsupported orientation"),
|
||||
_ => ThrowArgumentException()
|
||||
};
|
||||
|
||||
private static Rect ThrowArgumentException() => throw new ArgumentException("The input orientation is not valid.");
|
||||
}
|
||||
|
||||
private struct Row
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Microsoft.Toolkit.Uwp.UI.Media;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
|
@ -50,14 +49,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
{
|
||||
if (Target is not TEffect target)
|
||||
{
|
||||
return ThrowHelper.ThrowArgumentNullException<AnimationBuilder>("The target effect is null, make sure to set the Target property");
|
||||
static AnimationBuilder ThrowArgumentNullException() => throw new ArgumentNullException("The target effect is null, make sure to set the Target property");
|
||||
|
||||
return ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
if (ExplicitTarget is not string explicitTarget)
|
||||
{
|
||||
return ThrowHelper.ThrowArgumentNullException<AnimationBuilder>(
|
||||
"The target effect cannot be animated at this time. If you're targeting one of the " +
|
||||
"built-in effects, make sure that the PipelineEffect.IsAnimatable property is set to true.");
|
||||
static AnimationBuilder ThrowArgumentNullException()
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"The target effect cannot be animated at this time. If you're targeting one of the " +
|
||||
"built-in effects, make sure that the PipelineEffect.IsAnimatable property is set to true.");
|
||||
}
|
||||
|
||||
return ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
NormalizedKeyFrameAnimationBuilder<TKeyFrame>.Composition keyFrameBuilder = new(
|
||||
|
@ -70,7 +76,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
|
|||
|
||||
CompositionAnimation animation = keyFrameBuilder.GetAnimation(target.Brush!, out _);
|
||||
|
||||
return builder.ExternalAnimation(target.Brush, animation);
|
||||
return builder.ExternalAnimation(target.Brush!, animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Helpers
|
||||
|
@ -22,7 +21,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Helpers
|
|||
/// <returns>Awaitable Task</returns>
|
||||
public static Task<bool> ExecuteAfterCompositionRenderingAsync(Action action)
|
||||
{
|
||||
Guard.IsNotNull(action, nameof(action));
|
||||
if (action is null)
|
||||
{
|
||||
ThrowArgumentNullException();
|
||||
}
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
|
@ -45,6 +47,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Helpers
|
|||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
|
||||
static void ThrowArgumentNullException() => throw new ArgumentNullException("The parameter \"action\" must not be null.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.UI;
|
||||
using Color = Windows.UI.Color;
|
||||
|
||||
|
@ -24,7 +23,10 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
/// <returns>The created <see cref="Color"/>.</returns>
|
||||
public static Color ToColor(this string colorString)
|
||||
{
|
||||
Guard.IsNotNullOrEmpty(colorString, nameof(colorString));
|
||||
if (string.IsNullOrEmpty(colorString))
|
||||
{
|
||||
ThrowArgumentException();
|
||||
}
|
||||
|
||||
if (colorString[0] == '#')
|
||||
{
|
||||
|
@ -79,7 +81,7 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
return Color.FromArgb(255, r, g, b);
|
||||
}
|
||||
|
||||
default: return ThrowHelper.ThrowFormatException<Color>("The string passed in the colorString argument is not a recognized Color format.");
|
||||
default: return ThrowFormatException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +108,7 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
return Color.FromArgb(255, (byte)(scR * 255), (byte)(scG * 255), (byte)(scB * 255));
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowFormatException<Color>("The string passed in the colorString argument is not a recognized Color format (sc#[scA,]scR,scG,scB).");
|
||||
return ThrowFormatException();
|
||||
}
|
||||
|
||||
var prop = typeof(Colors).GetTypeInfo().GetDeclaredProperty(colorString);
|
||||
|
@ -116,7 +118,10 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
return (Color)prop.GetValue(null);
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowFormatException<Color>("The string passed in the colorString argument is not a recognized Color.");
|
||||
return ThrowFormatException();
|
||||
|
||||
static void ThrowArgumentException() => throw new ArgumentException("The parameter \"colorString\" must not be null or empty.");
|
||||
static Color ThrowFormatException() => throw new FormatException("The parameter \"colorString\" is not a recognized Color format.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.Helpers
|
||||
|
@ -31,7 +30,9 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
return (T)Convert.ChangeType(value, type);
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowNotSupportedException<T>("This serializer can only handle primitive types and strings. Please implement your own IObjectSerializer for more complex scenarios.");
|
||||
return ThrowNotSupportedException();
|
||||
|
||||
static T ThrowNotSupportedException() => throw new NotSupportedException("This serializer can only handle primitive types and strings. Please implement your own IObjectSerializer for more complex scenarios.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче