Browse Source

Fix AVP1012 warnings in Avalonia.Base (#13717)

pull/13718/head
Julien Lebosquain 3 years ago
committed by GitHub
parent
commit
18a3c43e44
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Base/Input/PinchEventArgs.cs
  2. 2
      src/Avalonia.Base/Media/PolyLineSegment.cs
  3. 6
      src/Avalonia.Controls/TabItem.cs
  4. 27
      tests/Avalonia.Controls.UnitTests/TabControlTests.cs

2
src/Avalonia.Base/Input/PinchEventArgs.cs

@ -24,7 +24,7 @@ namespace Avalonia.Input
/// <summary>
/// Gets the angle of the pinch gesture, in degrees.
/// <summary>
/// </summary>
/// <remarks>
/// A pinch gesture is the movement of two pressed points closer together. This property is the measured angle of the line between those two points. Remember zero degrees is a line pointing up.
/// </remarks>

2
src/Avalonia.Base/Media/PolyLineSegment.cs

@ -39,6 +39,8 @@ namespace Avalonia.Media
/// Initializes a new instance of the <see cref="PolyLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
Justification = "Collection properties shouldn't be set with SetCurrentValue.")]
public PolyLineSegment(IEnumerable<Point> points)
{
Points = new Points(points);

6
src/Avalonia.Controls/TabItem.cs

@ -72,14 +72,14 @@ namespace Avalonia.Controls
{
if (Header != headered.Header)
{
Header = headered.Header;
SetCurrentValue(HeaderProperty, headered.Header);
}
}
else
{
if (!(obj.NewValue is Control))
{
Header = obj.NewValue;
SetCurrentValue(HeaderProperty, obj.NewValue);
}
}
}
@ -87,7 +87,7 @@ namespace Avalonia.Controls
{
if (Header == obj.OldValue)
{
Header = obj.NewValue;
SetCurrentValue(HeaderProperty, obj.NewValue);
}
}
}

27
tests/Avalonia.Controls.UnitTests/TabControlTests.cs

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia.Collections;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Selection;
@ -547,6 +546,32 @@ namespace Avalonia.Controls.UnitTests
Assert.Same(item, root.FocusManager.GetFocusedElement());
}
[Fact]
public void TabItem_Header_Should_Be_Settable_By_Style_When_DataContext_Is_Set()
{
var tabItem = new TabItem
{
DataContext = "Some DataContext"
};
_ = new TestRoot
{
Styles =
{
new Style(x => x.OfType<TabItem>())
{
Setters =
{
new Setter(HeaderedContentControl.HeaderProperty, "Header from style")
}
}
},
Child = tabItem
};
Assert.Equal("Header from style", tabItem.Header);
}
private static IControlTemplate TabControlTemplate()
{
return new FuncControlTemplate<TabControl>((parent, scope) =>

Loading…
Cancel
Save