Browse Source

Misc warning fixes (#14766)

* Fix XML doc warnings

* Fix nullability warnings

* Fix misc warnings
pull/14782/head
Julien Lebosquain 2 years ago
committed by GitHub
parent
commit
cac27ddfc0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      src/Android/Avalonia.Android/AndroidRuntimePlatform.cs
  2. 2
      src/Avalonia.Base/Data/Core/ExpressionNodes/Reflection/ReflectionIndexerNode.cs
  3. 3
      src/Avalonia.Base/Data/Core/ExpressionParseException.cs
  4. 2
      src/Avalonia.Base/Data/Core/Parsers/BindingExpressionVisitor.cs
  5. 3
      src/Avalonia.Base/Data/Core/UntypedBindingExpressionBase.cs
  6. 1
      src/Avalonia.Base/Media/FormattedText.cs
  7. 2
      src/Avalonia.Base/Rendering/Composition/Compositor.cs
  8. 1
      src/Avalonia.Controls.ColorPicker/Helpers/ColorPickerHelpers.cs
  9. 8
      src/Avalonia.Controls/NativeMenuItem.cs
  10. 1
      src/Avalonia.Controls/PullToRefresh/RefreshVisualizer.cs
  11. 4
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlControlTemplatePartsChecker.cs
  12. 2
      tests/Avalonia.Base.UnitTests/Data/Core/BindingExpressionTests.UpdateSourceTrigger.cs
  13. 2
      tests/Avalonia.Base.UnitTests/DispatcherTests.Exception.cs
  14. 10
      tests/Avalonia.Base.UnitTests/Input/KeyboardNavigationTests_XY.cs
  15. 2
      tests/Avalonia.Controls.UnitTests/VirtualizingStackPanelTests.cs
  16. 6
      tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs
  17. 9
      tests/Avalonia.RenderTests/Media/RelativePointTestPrimitivesHelper.cs

15
src/Android/Avalonia.Android/AndroidRuntimePlatform.cs

@ -1,4 +1,6 @@
using System;
#nullable enable
using System;
using Android.Content.PM;
using Android.Content;
using Avalonia.Platform;
@ -27,7 +29,7 @@ namespace Avalonia
internal class AndroidRuntimePlatform : StandardRuntimePlatform
{
private static readonly Lazy<RuntimePlatformInfo> Info = new(() =>
private static readonly Lazy<RuntimePlatformInfo> s_info = new(() =>
{
var isDesktop = IsRunningOnDesktop(App.Context);
var isTv = IsRunningOnTv(App.Context);
@ -41,12 +43,13 @@ namespace Avalonia
});
private static bool IsRunningOnDesktop(Context context) =>
context.PackageManager.HasSystemFeature("org.chromium.arc") ||
context.PackageManager.HasSystemFeature("org.chromium.arc.device_management");
context.PackageManager is { } packageManager &&
(packageManager.HasSystemFeature("org.chromium.arc") ||
packageManager.HasSystemFeature("org.chromium.arc.device_management"));
private static bool IsRunningOnTv(Context context) =>
context.PackageManager.HasSystemFeature(PackageManager.FeatureLeanback);
context.PackageManager?.HasSystemFeature(PackageManager.FeatureLeanback) == true;
public override RuntimePlatformInfo GetRuntimeInfo() => Info.Value;
public override RuntimePlatformInfo GetRuntimeInfo() => s_info.Value;
}
}

2
src/Avalonia.Base/Data/Core/ExpressionNodes/Reflection/ReflectionIndexerNode.cs

@ -15,7 +15,7 @@ namespace Avalonia.Data.Core.ExpressionNodes.Reflection;
[RequiresUnreferencedCode(TrimmingMessages.ReflectionBindingRequiresUnreferencedCodeMessage)]
internal sealed class ReflectionIndexerNode : CollectionNodeBase, ISettableNode
{
private static readonly BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly;
private const BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly;
private MethodInfo? _getter;
private MethodInfo? _setter;
private object?[]? _indexes;

3
src/Avalonia.Base/Data/Core/ExpressionParseException.cs

@ -3,8 +3,7 @@ using System;
namespace Avalonia.Data.Core
{
/// <summary>
/// Exception thrown when <see cref="ExpressionObserver"/> could not parse the provided
/// expression string.
/// Exception thrown when the provided binding expression string could not be parsed.
/// </summary>
#if !BUILDTASK
public

2
src/Avalonia.Base/Data/Core/Parsers/BindingExpressionVisitor.cs

@ -15,7 +15,7 @@ internal class BindingExpressionVisitor<TIn> : ExpressionVisitor
{
private static readonly PropertyInfo AvaloniaObjectIndexer;
private static readonly MethodInfo CreateDelegateMethod;
private static readonly string IndexerGetterName = "get_Item";
private const string IndexerGetterName = "get_Item";
private const string MultiDimensionalArrayGetterMethodName = "Get";
private readonly bool _enableDataValidation;
private readonly LambdaExpression _rootExpression;

3
src/Avalonia.Base/Data/Core/UntypedBindingExpressionBase.cs

@ -140,8 +140,7 @@ public abstract class UntypedBindingExpressionBase : BindingExpressionBase,
}
/// <summary>
/// Starts the binding expression following a call to
/// <see cref="AttachCore(IBindingExpressionSink, AvaloniaObject, AvaloniaProperty, BindingPriority)"/>.
/// Starts the binding expression following a call to <see cref="AttachCore"/>.
/// </summary>
public void Start() => Start(produceValue: true);

1
src/Avalonia.Base/Media/FormattedText.cs

@ -51,7 +51,6 @@ namespace Avalonia.Media
/// <param name="typeface">Type face used to display text.</param>
/// <param name="emSize">Font em size in visual units (1/96 of an inch).</param>
/// <param name="foreground">Foreground brush used to render text.</param>
/// <param name="features">Optional list of turned on/off features.</param>
public FormattedText(
string textToFormat,
CultureInfo culture,

2
src/Avalonia.Base/Rendering/Composition/Compositor.cs

@ -294,7 +294,7 @@ namespace Avalonia.Rendering.Composition
_objectSerializationHashSet.Contains(serializable);
/// <summary>
/// Attempts to get the Compositor instance that will be used by default for new <see cref="Avalonia.Controls.TopLevel"/>s
/// Attempts to get the Compositor instance that will be used by default for new TopLevels
/// created by the current platform backend.
///
/// This won't work for every single platform backend and backend settings, e. g. with web we'll need to have

1
src/Avalonia.Controls.ColorPicker/Helpers/ColorPickerHelpers.cs

@ -24,6 +24,7 @@ namespace Avalonia.Controls.Primitives
/// Generates a new bitmap of the specified size by changing a specific color component.
/// This will produce a gradient representing a sweep of all possible values of the color component.
/// </summary>
/// <param name="bgraPixelData">The target buffer which will contain the bitmap data on return.</param>
/// <param name="width">The pixel width (X, horizontal) of the resulting bitmap.</param>
/// <param name="height">The pixel height (Y, vertical) of the resulting bitmap.</param>
/// <param name="orientation">The orientation of the resulting bitmap (gradient direction).</param>

8
src/Avalonia.Controls/NativeMenuItem.cs

@ -1,5 +1,6 @@
using System;
using System.Windows.Input;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Media.Imaging;
using Avalonia.Metadata;
@ -65,11 +66,11 @@ namespace Avalonia.Controls
set => SetValue(IconProperty, value);
}
/// <inheritdoc cref="MenuItem.HeaderProperty"/>
/// <inheritdoc cref="HeaderedSelectingItemsControl.HeaderProperty"/>
public static readonly StyledProperty<string?> HeaderProperty =
AvaloniaProperty.Register<NativeMenuItem, string?>(nameof(Header));
/// <inheritdoc cref="MenuItem.Header"/>
/// <inheritdoc cref="HeaderedSelectingItemsControl.Header"/>
public string? Header
{
get => GetValue(HeaderProperty);
@ -134,10 +135,11 @@ namespace Avalonia.Controls
public static readonly StyledProperty<object?> CommandParameterProperty =
MenuItem.CommandParameterProperty.AddOwner<NativeMenuItem>();
/// <inheritdoc cref="InputElement.IsEnabledProperty"/>
public static readonly StyledProperty<bool> IsEnabledProperty =
AvaloniaProperty.Register<NativeMenuItem, bool>(nameof(IsEnabled), true);
/// <inheritdoc cref="MenuItem.IsEnabled"/>
/// <inheritdoc cref="InputElement.IsEnabled"/>
public bool IsEnabled
{
get => GetValue(IsEnabledProperty);

1
src/Avalonia.Controls/PullToRefresh/RefreshVisualizer.cs

@ -14,7 +14,6 @@ namespace Avalonia.Controls
{
public class RefreshVisualizer : ContentControl
{
private const int DefaultIndicatorSize = 24;
private const float MinimumIndicatorOpacity = 0.4f;
private const float ParallaxPositionRatio = 0.5f;
private double _executingRatio = 0.8;

4
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlControlTemplatePartsChecker.cs

@ -1,4 +1,6 @@
using System.Collections.Generic;
#nullable enable
using System.Collections.Generic;
using System.Linq;
using XamlX;
using XamlX.Ast;

2
tests/Avalonia.Base.UnitTests/Data/Core/BindingExpressionTests.UpdateSourceTrigger.cs

@ -1,3 +1,5 @@
#nullable enable
using Avalonia.Data;
using Avalonia.UnitTests;
using Xunit;

2
tests/Avalonia.Base.UnitTests/DispatcherTests.Exception.cs

@ -265,7 +265,7 @@ public partial class DispatcherTests
dispatcher.Post(ThrowAnException, DispatcherPriority.Normal);
dispatcher.RunJobs();
}
catch (Exception e)
catch (Exception)
{
// should be no exception here.
caughtCorrectException = false;

10
tests/Avalonia.Base.UnitTests/Input/KeyboardNavigationTests_XY.cs

@ -350,11 +350,11 @@ public class KeyboardNavigationTests_XY : ScopedTestBase
}
[Theory]
[InlineData(Key.Left, NavigationDirection.Left)]
[InlineData(Key.Right, NavigationDirection.Right)]
[InlineData(Key.Up, NavigationDirection.Up)]
[InlineData(Key.Down, NavigationDirection.Down)]
public void Arrow_Key_Should_Not_Be_Handled_If_No_Focus(Key key, NavigationDirection direction)
[InlineData(Key.Left)]
[InlineData(Key.Right)]
[InlineData(Key.Up)]
[InlineData(Key.Down)]
public void Arrow_Key_Should_Not_Be_Handled_If_No_Focus(Key key)
{
using var _ = UnitTestApplication.Start(TestServices.FocusableWindow);

2
tests/Avalonia.Controls.UnitTests/VirtualizingStackPanelTests.cs

@ -1144,7 +1144,7 @@ namespace Avalonia.Controls.UnitTests
{
ev.Container.AddHandler(Control.RequestBringIntoViewEvent, (_, e) =>
{
var dataContext = e.TargetObject.DataContext as ItemWithHeight;
var dataContext = (ItemWithHeight)e.TargetObject!.DataContext!;
e.TargetRect = new Rect(dataContext.Height - 50, 0, 50, 10);
});
};

6
tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs

@ -1005,7 +1005,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
</Button>
</Window>";
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
var button = window.FindControl<Button>("button");
var button = window.GetControl<Button>("button");
button.Tag = new GridLength(5, GridUnitType.Star);
@ -1985,7 +1985,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
<TextBlock Name='textBlock' Tag='{{Binding !BoolProperty}}'/>
</Window>";
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
var textBlock = window.FindControl<TextBlock>("textBlock");
var textBlock = window.GetControl<TextBlock>("textBlock");
var dataContext = new TestDataContext { BoolProperty = value };
window.DataContext = dataContext;
@ -2013,7 +2013,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
</TextBlock>
</Window>";
var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
var textBlock = window.FindControl<TextBlock>("textBlock");
var textBlock = window.GetControl<TextBlock>("textBlock");
var dataContext = new ImplicitConvertible("Green");
window.DataContext = dataContext;

9
tests/Avalonia.RenderTests/Media/RelativePointTestPrimitivesHelper.cs

@ -17,8 +17,8 @@ namespace Avalonia.Direct2D1.RenderTests.Media
{
private readonly IBrush? _brush;
private readonly bool _shadow;
private readonly IPen _line;
private static readonly Geometry s_Geometry = Geometry.Parse("m 80 200 c 40 20 150 -40 160 0 l 0 30 c -40 -30 -160 10 -160 -30 z");
private readonly IPen? _line;
private static readonly Geometry s_geometry = Geometry.Parse("m 80 200 c 40 20 150 -40 160 0 l 0 30 c -40 -30 -160 10 -160 -30 z");
public RelativePointTestPrimitivesHelper(IBrush? brush, bool shadow = false)
{
@ -42,8 +42,9 @@ namespace Avalonia.Direct2D1.RenderTests.Media
context.DrawRectangle(_brush, null, new Rect(20, 20, 200, 60));
context.DrawEllipse(_brush, null, new Rect(40, 100, 200, 20));
context.DrawLine(_line, new Point(60, 140), new Point(240, 160));
context.DrawGeometry(_brush, null, s_Geometry);
if (_line is not null)
context.DrawLine(_line, new Point(60, 140), new Point(240, 160));
context.DrawGeometry(_brush, null, s_geometry);
base.Render(context);
}

Loading…
Cancel
Save