Browse Source

Fixed argument exception constructor calls.

Use nameof where possible.
Fixed wrong check in RelativeSource.AncestorLevel.
pull/2337/head
José Pedro 8 years ago
parent
commit
48dccadfb0
No known key found for this signature in database GPG Key ID: B8247B9301707B83
  1. 2
      samples/BindingDemo/ViewModels/ExceptionErrorViewModel.cs
  2. 2
      src/Avalonia.Base/Data/Core/Plugins/MethodAccessorPlugin.cs
  3. 4
      src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
  4. 2
      src/Avalonia.Remote.Protocol/MetsysBson.cs
  5. 2
      src/Avalonia.Visuals/Visual.cs
  6. 2
      src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs
  7. 4
      src/Markup/Avalonia.Markup/Data/RelativeSource.cs

2
samples/BindingDemo/ViewModels/ExceptionErrorViewModel.cs

@ -21,7 +21,7 @@ namespace BindingDemo.ViewModels
} }
else else
{ {
throw new ArgumentOutOfRangeException("Value must be less than 10."); throw new ArgumentOutOfRangeException(nameof(value), "Value must be less than 10.");
} }
} }
} }

2
src/Avalonia.Base/Data/Core/Plugins/MethodAccessorPlugin.cs

@ -21,7 +21,7 @@ namespace Avalonia.Data.Core.Plugins
{ {
if (method.GetParameters().Length + (method.ReturnType == typeof(void) ? 0 : 1) > 8) if (method.GetParameters().Length + (method.ReturnType == typeof(void) ? 0 : 1) > 8)
{ {
var exception = new ArgumentException("Cannot create a binding accessor for a method with more than 8 parameters or more than 7 parameters if it has a non-void return type.", nameof(method)); var exception = new ArgumentException("Cannot create a binding accessor for a method with more than 8 parameters or more than 7 parameters if it has a non-void return type.", nameof(methodName));
return new PropertyError(new BindingNotification(exception, BindingErrorType.Error)); return new PropertyError(new BindingNotification(exception, BindingErrorType.Error));
} }

4
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs

@ -965,11 +965,11 @@ namespace Avalonia.Controls
{ {
if (value < Minimum) if (value < Minimum)
{ {
throw new ArgumentOutOfRangeException(nameof(Minimum), string.Format("Value must be greater than Minimum value of {0}", Minimum)); throw new ArgumentOutOfRangeException(nameof(value), string.Format("Value must be greater than Minimum value of {0}", Minimum));
} }
else if (value > Maximum) else if (value > Maximum)
{ {
throw new ArgumentOutOfRangeException(nameof(Maximum), string.Format("Value must be less than Maximum value of {0}", Maximum)); throw new ArgumentOutOfRangeException(nameof(value), string.Format("Value must be less than Maximum value of {0}", Maximum));
} }
} }

2
src/Avalonia.Remote.Protocol/MetsysBson.cs

@ -749,7 +749,7 @@ namespace Metsys.Bson
if (memberExpression.Expression.NodeType != ExpressionType.Parameter && memberExpression.Expression.NodeType != ExpressionType.Convert) if (memberExpression.Expression.NodeType != ExpressionType.Parameter && memberExpression.Expression.NodeType != ExpressionType.Convert)
{ {
throw new ArgumentException(string.Format("Expression '{0}' must resolve to top-level member.", lambdaExpression), "lambdaExpression"); throw new ArgumentException(string.Format("Expression '{0}' must resolve to top-level member.", lambdaExpression), nameof(lambdaExpression));
} }
return memberExpression.Member.Name; return memberExpression.Member.Name;
default: default:

2
src/Avalonia.Visuals/Visual.cs

@ -551,7 +551,7 @@ namespace Avalonia
{ {
if (c == null) if (c == null)
{ {
throw new ArgumentNullException("Cannot add null to VisualChildren."); throw new ArgumentNullException(nameof(c), "Cannot add null to VisualChildren.");
} }
if (c.VisualParent != null) if (c.VisualParent != null)

2
src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs

@ -84,7 +84,7 @@ namespace Avalonia.Gtk3
public RenderOp(GtkWidget widget, ManagedCairoSurface surface, double factor, int width, int height) public RenderOp(GtkWidget widget, ManagedCairoSurface surface, double factor, int width, int height)
{ {
_widget = widget; _widget = widget;
_surface = surface ?? throw new ArgumentNullException(); _surface = surface ?? throw new ArgumentNullException(nameof(surface));
_factor = factor; _factor = factor;
_width = width; _width = width;
_height = height; _height = height;

4
src/Markup/Avalonia.Markup/Data/RelativeSource.cs

@ -85,9 +85,9 @@ namespace Avalonia.Data
get { return _ancestorLevel; } get { return _ancestorLevel; }
set set
{ {
if (_ancestorLevel <= 0) if (value <= 0)
{ {
throw new ArgumentOutOfRangeException("AncestorLevel may not be set to less than 1."); throw new ArgumentOutOfRangeException(nameof(value), "AncestorLevel may not be set to less than 1.");
} }
_ancestorLevel = value; _ancestorLevel = value;

Loading…
Cancel
Save