Skip to content

Commit

Permalink
Remove ignored validate parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed Nov 14, 2019
1 parent 6be3acb commit 0cfa159
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 29 deletions.
6 changes: 2 additions & 4 deletions src/Avalonia.Base/AvaloniaProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ public static AttachedProperty<TValue> RegisterAttached<TOwner, THost, TValue>(
string name,
TValue defaultValue = default(TValue),
bool inherits = false,
BindingMode defaultBindingMode = BindingMode.OneWay,
Func<THost, TValue, TValue> validate = null)
BindingMode defaultBindingMode = BindingMode.OneWay)
where THost : IAvaloniaObject
{
Contract.Requires<ArgumentNullException>(name != null);
Expand Down Expand Up @@ -335,8 +334,7 @@ public static AttachedProperty<TValue> RegisterAttached<THost, TValue>(
Type ownerType,
TValue defaultValue = default(TValue),
bool inherits = false,
BindingMode defaultBindingMode = BindingMode.OneWay,
Func<THost, TValue, TValue> validate = null)
BindingMode defaultBindingMode = BindingMode.OneWay)
where THost : IAvaloniaObject
{
Contract.Requires<ArgumentNullException>(name != null);
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Controls/DefinitionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@ private void OnLayoutUpdated(object sender, EventArgs e)
/// </remarks>
public static readonly AttachedProperty<string> SharedSizeGroupProperty =
AvaloniaProperty.RegisterAttached<DefinitionBase, Control, string>(
"SharedSizeGroup",
validate: SharedSizeGroupPropertyValueValid);
"SharedSizeGroup"/*,
validate: SharedSizeGroupPropertyValueValid*/);

/// <summary>
/// Static ctor. Used for static registration of properties.
Expand Down
16 changes: 8 additions & 8 deletions src/Avalonia.Controls/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2740,12 +2740,12 @@ private enum Flags
public static readonly AttachedProperty<int> ColumnProperty =
AvaloniaProperty.RegisterAttached<Grid, Control, int>(
"Column",
defaultValue: 0,
defaultValue: 0/*,
validate: (_, v) =>
{
if (v >= 0) return v;
else throw new ArgumentException("Invalid Grid.Column value.");
});
}*/);

/// <summary>
/// Row property. This is an attached property.
Expand All @@ -2761,12 +2761,12 @@ private enum Flags
public static readonly AttachedProperty<int> RowProperty =
AvaloniaProperty.RegisterAttached<Grid, Control, int>(
"Row",
defaultValue: 0,
defaultValue: 0/*,
validate: (_, v) =>
{
if (v >= 0) return v;
else throw new ArgumentException("Invalid Grid.Row value.");
});
}*/);

/// <summary>
/// ColumnSpan property. This is an attached property.
Expand All @@ -2781,12 +2781,12 @@ private enum Flags
public static readonly AttachedProperty<int> ColumnSpanProperty =
AvaloniaProperty.RegisterAttached<Grid, Control, int>(
"ColumnSpan",
defaultValue: 1,
defaultValue: 1/*,
validate: (_, v) =>
{
if (v >= 1) return v;
else throw new ArgumentException("Invalid Grid.ColumnSpan value.");
});
}*/);

/// <summary>
/// RowSpan property. This is an attached property.
Expand All @@ -2801,12 +2801,12 @@ private enum Flags
public static readonly AttachedProperty<int> RowSpanProperty =
AvaloniaProperty.RegisterAttached<Grid, Control, int>(
"RowSpan",
defaultValue: 1,
defaultValue: 1/*,
validate: (_, v) =>
{
if (v >= 1) return v;
else throw new ArgumentException("Invalid Grid.RowSpan value.");
});
}*/);

/// <summary>
/// IsSharedSizeScope property marks scoping element for shared size.
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Controls/NativeMenu.Export.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ static void SetIsNativeMenuExported(TopLevel tl, bool value)
}

public static readonly AttachedProperty<NativeMenu> MenuProperty
= AvaloniaProperty.RegisterAttached<NativeMenu, AvaloniaObject, NativeMenu>("Menu", validate:
= AvaloniaProperty.RegisterAttached<NativeMenu, AvaloniaObject, NativeMenu>("Menu"/*, validate:
(o, v) =>
{
if(!(o is Application || o is TopLevel))
throw new InvalidOperationException("NativeMenu.Menu property isn't valid on "+o.GetType());
return v;
});
}*/);

public static void SetMenu(AvaloniaObject o, NativeMenu menu) => o.SetValue(MenuProperty, menu);
public static NativeMenu GetMenu(AvaloniaObject o) => o.GetValue(MenuProperty);
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/Notifications/NotificationCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static void SetCloseOnClick(Button obj, bool value)
/// Defines the CloseOnClick property.
/// </summary>
public static readonly AvaloniaProperty CloseOnClickProperty =
AvaloniaProperty.RegisterAttached<Button, bool>("CloseOnClick", typeof(NotificationCard), validate: CloseOnClickChanged);
AvaloniaProperty.RegisterAttached<Button, bool>("CloseOnClick", typeof(NotificationCard)/*, validate: CloseOnClickChanged*/);

private static bool CloseOnClickChanged(Button button, bool value)
{
Expand Down
13 changes: 1 addition & 12 deletions tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Attached.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,7 @@ private class Class1 : Base
public static readonly AttachedProperty<string> FooProperty =
AvaloniaProperty.RegisterAttached<Class1, Base, string>(
"Foo",
"foodefault",
validate: ValidateFoo);

private static string ValidateFoo(AvaloniaObject arg1, string arg2)
{
if (arg2 == "throw")
{
throw new IndexOutOfRangeException();
}

return arg2;
}
"foodefault");
}

private class Class2 : Base
Expand Down

0 comments on commit 0cfa159

Please sign in to comment.