Browse Source

Ported warning fixes from #4882.

Co-Authored-By: workgroupengineering <workgroupengineering@users.noreply.github.com>
fixes/less-warnings
Steven Kirk 5 years ago
parent
commit
c74e5726fc
  1. 2
      src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs
  2. 7
      src/Avalonia.Controls.DataGrid/Collections/DataGridGroupDescription.cs
  3. 3
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  4. 7
      src/Avalonia.Controls.DataGrid/Utils/CellEditBinding.cs
  5. 2
      src/Avalonia.Controls/Application.cs
  6. 2
      src/Avalonia.Controls/Border.cs
  7. 3
      src/Avalonia.Controls/Grid.cs
  8. 3
      src/Avalonia.Controls/Menu.cs
  9. 3
      src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs
  10. 8
      src/Avalonia.Controls/Primitives/Popup.cs
  11. 4
      src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs
  12. 2
      src/Avalonia.Controls/Primitives/TemplatedControl.cs
  13. 2
      src/Avalonia.Controls/ProgressBar.cs
  14. 7
      src/Avalonia.Controls/Remote/RemoteServer.cs
  15. 2
      src/Avalonia.Controls/Remote/RemoteWidget.cs
  16. 9
      src/Avalonia.Controls/Repeater/ViewportManager.cs
  17. 1
      src/Avalonia.Controls/Repeater/VirtualizationInfo.cs
  18. 12
      src/Avalonia.Controls/SplitView.cs
  19. 4
      src/Avalonia.Controls/TextBox.cs
  20. 2
      src/Avalonia.Controls/TextBoxTextInputMethodClient.cs
  21. 2
      src/Avalonia.DesignerSupport/Remote/FileWatcherTransport.cs
  22. 2
      src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs
  23. 2
      src/Avalonia.Diagnostics/Diagnostics/Views/ConsoleView.xaml.cs
  24. 4
      src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
  25. 4
      src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml.cs
  26. 2
      src/Avalonia.Dialogs/ManagedFileChooser.xaml.cs
  27. 2
      src/Avalonia.Dialogs/ManagedFileChooserSources.cs
  28. 2
      src/Avalonia.FreeDesktop/DBusMenuExporter.cs
  29. 2
      src/Avalonia.Input/Gestures.cs
  30. 5
      src/Avalonia.Input/ICommandSource.cs
  31. 2
      src/Avalonia.Input/MouseDevice.cs
  32. 2
      src/Avalonia.Native/AvaloniaNativeMenuExporter.cs
  33. 4
      src/Avalonia.Styling/Styling/Setter.cs
  34. 6
      src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs
  35. 5
      src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
  36. 2
      src/Avalonia.Visuals/Vector.cs
  37. 1
      src/Avalonia.X11/TransparencyHelper.cs
  38. 2
      src/Avalonia.X11/X11Window.Ime.cs
  39. 4
      src/Avalonia.X11/X11Window.Xim.cs
  40. 9
      src/Avalonia.X11/X11Window.cs
  41. 1
      src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs
  42. 1
      src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
  43. 3
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlCompiler.cs
  44. 71
      src/Markup/Avalonia.Markup/Markup/Parsers/PropertyPathGrammar.cs
  45. 1
      src/Skia/Avalonia.Skia/Gpu/ISkiaGpu.cs
  46. 2
      src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaGpu.cs
  47. 1
      src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs
  48. 1
      src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs
  49. 9
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
  50. 2
      src/tools/MicroComGenerator/CSharpGen.Utils.cs
  51. 2
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

2
src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs

@ -170,7 +170,7 @@ namespace Avalonia.Data.Converters
.Compile();
}
private static Expression? ConvertTarget(object? target, MethodInfo method) =>
private static Expression ConvertTarget(object target, MethodInfo method) =>
target is null ? null : Expression.Convert(Expression.Constant(target), method.DeclaringType);
internal class WeakPropertyChangedProxy

7
src/Avalonia.Controls.DataGrid/Collections/DataGridGroupDescription.cs

@ -58,7 +58,6 @@ namespace Avalonia.Collections
{
private string _propertyPath;
private Type _propertyType;
private IValueConverter _valueConverter;
private StringComparison _stringComparison = StringComparison.Ordinal;
public DataGridPathGroupDescription(string propertyPath)
@ -83,8 +82,8 @@ namespace Avalonia.Collections
if (key == null)
key = item;
if (_valueConverter != null)
key = _valueConverter.Convert(key, typeof(object), level, culture);
if (ValueConverter != null)
key = ValueConverter.Convert(key, typeof(object), level, culture);
return key;
}
@ -99,6 +98,8 @@ namespace Avalonia.Collections
}
public override string PropertyName => _propertyPath;
public IValueConverter ValueConverter { get; set; }
private Type GetPropertyType(object o)
{
return o.GetType().GetNestedPropertyType(_propertyPath);

3
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -75,7 +75,6 @@ namespace Avalonia.Controls
private const double DATAGRID_defaultMinColumnWidth = 20;
private const double DATAGRID_defaultMaxColumnWidth = double.PositiveInfinity;
private List<Exception> _validationErrors;
private List<Exception> _bindingValidationErrors;
private IDisposable _validationSubscription;
@ -102,7 +101,6 @@ namespace Avalonia.Controls
private bool _areHandlersSuspended;
private bool _autoSizingColumns;
private IndexToValueTable<bool> _collapsedSlotsTable;
private DataGridCellCoordinates _currentCellCoordinates;
private Control _clickedElement;
// used to store the current column during a Reset
@ -141,7 +139,6 @@ namespace Avalonia.Controls
private DataGridSelectedItemsCollection _selectedItems;
private bool _temporarilyResetCurrentCell;
private object _uneditedValue; // Represents the original current cell value at the time it enters editing mode.
private ICellEditBinding _currentCellEditBinding;
// An approximation of the sum of the heights in pixels of the scrolling rows preceding
// the first displayed scrolling row. Since the scrolled off rows are discarded, the grid

7
src/Avalonia.Controls.DataGrid/Utils/CellEditBinding.cs

@ -57,7 +57,6 @@ namespace Avalonia.Controls.Utils
private IDisposable _subscription;
private object _controlValue;
private bool _isControlValueSet = false;
private bool _settingSourceValue = false;
public SubjectWrapper(ISubject<object> bindingSourceSubject, CellEditBinding editBinding)
{
@ -67,11 +66,7 @@ namespace Avalonia.Controls.Utils
private void SetSourceValue(object value)
{
_settingSourceValue = true;
_sourceSubject.OnNext(value);
_settingSourceValue = false;
}
private void SetControlValue(object value)
{
@ -157,4 +152,4 @@ namespace Avalonia.Controls.Utils
}
}
}
}
}

2
src/Avalonia.Controls/Application.cs

@ -155,7 +155,7 @@ namespace Avalonia
/// <inheritdoc/>
bool IResourceNode.HasResources => (_resources?.HasResources ?? false) ||
(((IResourceNode?)_styles)?.HasResources ?? false);
(((IResourceNode)_styles)?.HasResources ?? false);
/// <summary>
/// Gets the styling parent of the application, which is null.

2
src/Avalonia.Controls/Border.cs

@ -8,7 +8,9 @@ namespace Avalonia.Controls
/// <summary>
/// A control which decorates a child with a border and background.
/// </summary>
#pragma warning disable CS0618 // Type or member is obsolete
public partial class Border : Decorator, IVisualWithRoundRectClip
#pragma warning restore CS0618 // Type or member is obsolete
{
/// <summary>
/// Defines the <see cref="Background"/> property.

3
src/Avalonia.Controls/Grid.cs

@ -978,6 +978,9 @@ namespace Avalonia.Controls
/// width is not registered in columns.</param>
/// <param name="forceInfinityV">Passed through to MeasureCell.
/// When "true" cells' desired height is not registered in rows.</param>
/// <param name="hasDesiredSizeUChanged">
/// When the method exits, indicates where the desired size has changed.
/// </param>
private void MeasureCellsGroup(
int cellsHead,
Size referenceSize,

3
src/Avalonia.Controls/Menu.cs

@ -1,5 +1,4 @@
using Avalonia.Controls.Platform;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.Interactivity;
@ -17,8 +16,6 @@ namespace Avalonia.Controls
private static readonly ITemplate<IPanel> DefaultPanel =
new FuncTemplate<IPanel>(() => new StackPanel { Orientation = Orientation.Horizontal });
private LightDismissOverlayLayer? _overlay;
/// <summary>
/// Initializes a new instance of the <see cref="Menu"/> class.
/// </summary>

3
src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs

@ -83,7 +83,8 @@ namespace Avalonia.Controls.Platform
public bool CurrentThreadIsLoopThread => TlsCurrentThreadIsLoopThread;
public event Action<DispatcherPriority?> Signaled;
#pragma warning disable CS0067
public event Action<TimeSpan> Tick;
#pragma warning restore CS0067
}
}

8
src/Avalonia.Controls/Primitives/Popup.cs

@ -87,8 +87,8 @@ namespace Avalonia.Controls.Primitives
public static readonly StyledProperty<bool> OverlayDismissEventPassThroughProperty =
AvaloniaProperty.Register<Popup, bool>(nameof(OverlayDismissEventPassThrough));
public static readonly DirectProperty<Popup, IInputElement> OverlayInputPassThroughElementProperty =
AvaloniaProperty.RegisterDirect<Popup, IInputElement>(
public static readonly DirectProperty<Popup, IInputElement?> OverlayInputPassThroughElementProperty =
AvaloniaProperty.RegisterDirect<Popup, IInputElement?>(
nameof(OverlayInputPassThroughElement),
o => o.OverlayInputPassThroughElement,
(o, v) => o.OverlayInputPassThroughElement = v);
@ -132,7 +132,7 @@ namespace Avalonia.Controls.Primitives
private bool _isOpen;
private bool _ignoreIsOpenChanged;
private PopupOpenState? _openState;
private IInputElement _overlayInputPassThroughElement;
private IInputElement? _overlayInputPassThroughElement;
/// <summary>
/// Initializes static members of the <see cref="Popup"/> class.
@ -299,7 +299,7 @@ namespace Avalonia.Controls.Primitives
/// Gets or sets an element that should receive pointer input events even when underneath
/// the popup's overlay.
/// </summary>
public IInputElement OverlayInputPassThroughElement
public IInputElement? OverlayInputPassThroughElement
{
get => _overlayInputPassThroughElement;
set => SetAndRaise(OverlayInputPassThroughElementProperty, ref _overlayInputPassThroughElement, value);

4
src/Avalonia.Controls/Primitives/PopupPositioning/IPopupPositioner.cs

@ -448,8 +448,10 @@ namespace Avalonia.Controls.Primitives.PopupPositioning
PopupPositionerConstraintAdjustment constraintAdjustment, Rect? rect)
{
// We need a better way for tracking the last pointer position
#pragma warning disable CS0618 // Type or member is obsolete
var pointer = topLevel.PointToClient(topLevel.PlatformImpl.MouseDevice.Position);
#pragma warning restore CS0618 // Type or member is obsolete
positionerParameters.Offset = offset;
positionerParameters.ConstraintAdjustment = constraintAdjustment;
if (placement == PlacementMode.Pointer)

2
src/Avalonia.Controls/Primitives/TemplatedControl.cs

@ -265,7 +265,9 @@ namespace Avalonia.Controls.Primitives
var e = new TemplateAppliedEventArgs(nameScope);
OnApplyTemplate(e);
#pragma warning disable CS0618 // Type or member is obsolete
OnTemplateApplied(e);
#pragma warning restore CS0618 // Type or member is obsolete
RaiseEvent(e);
}

2
src/Avalonia.Controls/ProgressBar.cs

@ -217,8 +217,10 @@ namespace Avalonia.Controls
TemplateProperties.Container2AnimationEndPosition = barIndicatorWidth2 * 1.66; // Position at 166%
// Remove these properties when we switch to fluent as default and removed the old one.
#pragma warning disable CS0618 // Type or member is obsolete
IndeterminateStartingOffset = -dim;
IndeterminateEndingOffset = dim;
#pragma warning restore CS0618 // Type or member is obsolete
var padding = Padding;
var rectangle = new RectangleGeometry(

7
src/Avalonia.Controls/Remote/RemoteServer.cs

@ -1,7 +1,5 @@
using System;
using Avalonia.Controls.Embedding;
using Avalonia.Controls.Embedding;
using Avalonia.Controls.Remote.Server;
using Avalonia.Platform;
using Avalonia.Remote.Protocol;
namespace Avalonia.Controls.Remote
@ -15,9 +13,6 @@ namespace Avalonia.Controls.Remote
public EmbeddableRemoteServerTopLevelImpl(IAvaloniaRemoteTransportConnection transport) : base(transport)
{
}
#pragma warning disable 67
public Action LostFocus { get; set; }
}
public RemoteServer(IAvaloniaRemoteTransportConnection transport)

2
src/Avalonia.Controls/Remote/RemoteWidget.cs

@ -77,8 +77,10 @@ namespace Avalonia.Controls.Remote
_bitmap.PixelSize.Height != _lastFrame.Height)
{
_bitmap?.Dispose();
#pragma warning disable CS0618 // Type or member is obsolete
_bitmap = new WriteableBitmap(new PixelSize(_lastFrame.Width, _lastFrame.Height),
new Vector(96, 96), fmt);
#pragma warning restore CS0618 // Type or member is obsolete
}
using (var l = _bitmap.Lock())
{

9
src/Avalonia.Controls/Repeater/ViewportManager.cs

@ -4,16 +4,8 @@
// Licensed to The Avalonia Project under MIT License, courtesy of The .NET Foundation.
using System;
using System.Collections.Generic;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Avalonia.Controls.Presenters;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Logging;
using Avalonia.Media;
using Avalonia.Reactive;
using Avalonia.Threading;
using Avalonia.VisualTree;
@ -27,7 +19,6 @@ namespace Avalonia.Controls
private IScrollAnchorProvider _scroller;
private IControl _makeAnchorElement;
private bool _isAnchorOutsideRealizedRange;
private Task _cacheBuildAction;
private Rect _visibleWindow;
private Rect _layoutExtent;
// This is the expected shift by the layout.

1
src/Avalonia.Controls/Repeater/VirtualizationInfo.cs

@ -27,7 +27,6 @@ namespace Avalonia.Controls
internal class VirtualizationInfo
{
private int _pinCounter;
private object _data;
public Rect ArrangeBounds { get; set; }
public bool AutoRecycleCandidate { get; set; }

12
src/Avalonia.Controls/SplitView.cs

@ -129,14 +129,14 @@ namespace Avalonia.Controls
/// <summary>
/// Defines the <see cref="Pane"/> property
/// </summary>
public static readonly StyledProperty<object?> PaneProperty =
AvaloniaProperty.Register<SplitView, object?>(nameof(Pane));
public static readonly StyledProperty<object> PaneProperty =
AvaloniaProperty.Register<SplitView, object>(nameof(Pane));
/// <summary>
/// Defines the <see cref="HeaderTemplate"/> property.
/// Defines the <see cref="PaneTemplate"/> property.
/// </summary>
public static readonly StyledProperty<IDataTemplate?> PaneTemplateProperty =
AvaloniaProperty.Register<HeaderedContentControl, IDataTemplate?>(nameof(PaneTemplate));
public static readonly StyledProperty<IDataTemplate> PaneTemplateProperty =
AvaloniaProperty.Register<HeaderedContentControl, IDataTemplate>(nameof(PaneTemplate));
/// <summary>
/// Defines the <see cref="UseLightDismissOverlayMode"/> property
@ -267,7 +267,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the data template used to display the header content of the control.
/// </summary>
public IDataTemplate? PaneTemplate
public IDataTemplate PaneTemplate
{
get => GetValue(PaneTemplateProperty);
set => SetValue(PaneTemplateProperty, value);

4
src/Avalonia.Controls/TextBox.cs

@ -542,7 +542,9 @@ namespace Avalonia.Controls
return text;
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async void Cut()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var text = GetSelection();
if (text is null) return;
@ -842,7 +844,9 @@ namespace Avalonia.Controls
{
var point = e.GetPosition(_presenter);
var index = CaretIndex = _presenter.GetCaretIndex(point);
#pragma warning disable CS0618 // Type or member is obsolete
switch (e.ClickCount)
#pragma warning restore CS0618 // Type or member is obsolete
{
case 1:
SelectionStart = SelectionEnd = index;

2
src/Avalonia.Controls/TextBoxTextInputMethodClient.cs

@ -18,7 +18,7 @@ namespace Avalonia.Controls
public bool SupportsSurroundingText => false;
public TextInputMethodSurroundingText SurroundingText => throw new NotSupportedException();
public event EventHandler SurroundingTextChanged;
public event EventHandler SurroundingTextChanged { add { } remove { } }
public string TextBeforeCursor => null;
public string TextAfterCursor => null;

2
src/Avalonia.DesignerSupport/Remote/FileWatcherTransport.cs

@ -59,7 +59,7 @@ namespace Avalonia.DesignerSupport.Remote
remove { _onMessage -= value; }
}
public event Action<IAvaloniaRemoteTransportConnection, Exception> OnException;
public event Action<IAvaloniaRemoteTransportConnection, Exception> OnException { add { } remove { } }
public void Start()
{
UpdaterThread();

2
src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs

@ -25,7 +25,6 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport
private AutoResetEvent _wakeup = new AutoResetEvent(false);
private FrameMessage _lastFrameMessage = null;
private FrameMessage _lastSentFrameMessage = null;
private RequestViewportResizeMessage _lastViewportRequest;
private Action<IAvaloniaRemoteTransportConnection, object> _onMessage;
private Action<IAvaloniaRemoteTransportConnection, Exception> _onException;
@ -177,6 +176,7 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport
public void Dispose()
{
_disposed = true;
_pendingSocket?.Dispose();
_simpleServer.Dispose();
}

2
src/Avalonia.Diagnostics/Diagnostics/Views/ConsoleView.xaml.cs

@ -45,7 +45,7 @@ namespace Avalonia.Diagnostics.Views
switch (e.Key)
{
case Key.Enter:
vm.Execute();
_ = vm.Execute();
e.Handled = true;
break;
case Key.Up:

4
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs

@ -75,8 +75,10 @@ namespace Avalonia.Diagnostics.Views
if (e.Modifiers == modifiers)
{
#pragma warning disable CS0618 // Type or member is obsolete
var point = (Root as IInputRoot)?.MouseDevice?.GetPosition(Root) ?? default;
#pragma warning restore CS0618 // Type or member is obsolete
var control = Root.GetVisualsAt(point, x =>
{
if (x is AdornerLayer || !x.IsVisible) return false;

4
src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml.cs

@ -30,13 +30,13 @@ namespace Avalonia.Dialogs
}
else
{
using (Process process = Process.Start(new ProcessStartInfo
using var process = Process.Start(new ProcessStartInfo
{
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"{url}" : "",
CreateNoWindow = true,
UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
}));
});
}
}

2
src/Avalonia.Dialogs/ManagedFileChooser.xaml.cs

@ -35,7 +35,9 @@ namespace Avalonia.Dialogs
}
var isQuickLink = _quickLinksRoot.IsLogicalAncestorOf(e.Source as Control);
#pragma warning disable CS0618 // Type or member is obsolete
if (e.ClickCount == 2 || isQuickLink)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (model.ItemType == ManagedFileChooserItemType.File)
{

2
src/Avalonia.Dialogs/ManagedFileChooserSources.cs

@ -67,7 +67,7 @@ namespace Avalonia.Dialogs
{
Directory.GetFiles(x.VolumePath);
}
catch (UnauthorizedAccessException _)
catch (UnauthorizedAccessException)
{
return null;
}

2
src/Avalonia.FreeDesktop/DBusMenuExporter.cs

@ -377,11 +377,13 @@ namespace Avalonia.FreeDesktop
#region Events
#pragma warning disable CS0067
private event Action<((int, IDictionary<string, object>)[] updatedProps, (int, string[])[] removedProps)>
ItemsPropertiesUpdated;
private event Action<(uint revision, int parent)> LayoutUpdated;
private event Action<(int id, uint timestamp)> ItemActivationRequested;
private event Action<PropertyChanges> PropertiesChanged;
#pragma warning restore CS0067
async Task<IDisposable> IDBusMenu.WatchItemsPropertiesUpdatedAsync(Action<((int, IDictionary<string, object>)[] updatedProps, (int, string[])[] removedProps)> handler, Action<Exception> onError)
{

2
src/Avalonia.Input/Gestures.cs

@ -81,6 +81,7 @@ namespace Avalonia.Input
var e = (PointerPressedEventArgs)ev;
var visual = (IVisual)ev.Source;
#pragma warning disable CS0618 // Type or member is obsolete
if (e.ClickCount <= 1)
{
s_lastPress = new WeakReference<IInteractive>(ev.Source);
@ -92,6 +93,7 @@ namespace Avalonia.Input
e.Source.RaiseEvent(new RoutedEventArgs(DoubleTappedEvent));
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}
}

5
src/Avalonia.Input/ICommandSource.cs

@ -12,14 +12,13 @@ namespace Avalonia.Input
/// Classes that implement this interface should enable or disable based on the command's CanExecute return value.
/// The property may be implemented as read-write if desired.
/// </summary>
ICommand Command { get; }
ICommand? Command { get; }
/// <summary>
/// The parameter that will be passed to the command when executing the command.
/// The property may be implemented as read-write if desired.
/// </summary>
object CommandParameter { get; }
object? CommandParameter { get; }
/// <summary>
/// Bor the bheavior CanExecuteChanged

2
src/Avalonia.Input/MouseDevice.cs

@ -75,7 +75,9 @@ namespace Avalonia.Input
throw new InvalidOperationException("Control is not attached to visual tree.");
}
#pragma warning disable CS0618 // Type or member is obsolete
var rootPoint = relativeTo.VisualRoot.PointToClient(Position);
#pragma warning restore CS0618 // Type or member is obsolete
var transform = relativeTo.VisualRoot.TransformToVisual(relativeTo);
return rootPoint * transform!.Value;
}

2
src/Avalonia.Native/AvaloniaNativeMenuExporter.cs

@ -35,7 +35,7 @@ namespace Avalonia.Native
public bool IsNativeMenuExported => _exported;
public event EventHandler OnIsNativeMenuExportedChanged;
public event EventHandler OnIsNativeMenuExportedChanged { add { } remove { } }
public void SetNativeMenu(NativeMenu menu)
{

4
src/Avalonia.Styling/Styling/Setter.cs

@ -102,7 +102,9 @@ namespace Avalonia.Styling
data.result = new PropertySetterInstance<T>(
data.target,
property,
#pragma warning disable CS8604 // Possible null reference argument.
(T)data.value);
#pragma warning restore CS8604 // Possible null reference argument.
}
}
@ -122,7 +124,9 @@ namespace Avalonia.Styling
data.result = new PropertySetterInstance<T>(
data.target,
property,
#pragma warning disable CS8604 // Possible null reference argument.
(T)data.value);
#pragma warning restore CS8604 // Possible null reference argument.
}
}

6
src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs

@ -289,11 +289,13 @@ namespace Avalonia.Rendering
using (context.PushPostTransform(m))
using (context.PushOpacity(opacity))
using (clipToBounds
? visual is IVisualWithRoundRectClip roundClipVisual
using (clipToBounds
#pragma warning disable CS0618 // Type or member is obsolete
? visual is IVisualWithRoundRectClip roundClipVisual
? context.PushClip(new RoundedRect(bounds, roundClipVisual.ClipToBoundsRadius))
: context.PushClip(bounds)
: default(DrawingContext.PushedState))
#pragma warning restore CS0618 // Type or member is obsolete
using (visual.Clip != null ? context.PushGeometryClip(visual.Clip) : default(DrawingContext.PushedState))
using (visual.OpacityMask != null ? context.PushOpacityMask(visual.OpacityMask, bounds) : default(DrawingContext.PushedState))
using (context.PushTransformContainer())

5
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

@ -164,10 +164,13 @@ namespace Avalonia.Rendering.SceneGraph
var visual = node.Visual;
var opacity = visual.Opacity;
var clipToBounds = visual.ClipToBounds;
#pragma warning disable CS0618 // Type or member is obsolete
var clipToBoundsRadius = visual is IVisualWithRoundRectClip roundRectClip ?
roundRectClip.ClipToBoundsRadius :
default;
#pragma warning restore CS0618 // Type or member is obsolete
var bounds = new Rect(visual.Bounds.Size);
var contextImpl = (DeferredDrawingContextImpl)context.PlatformImpl;

2
src/Avalonia.Visuals/Vector.cs

@ -166,7 +166,7 @@ namespace Avalonia
MathUtilities.AreClose(_y, other._y);
}
public override bool Equals(object obj) => obj is Vector other && Equals(other);
public override bool Equals(object? obj) => obj is Vector other && Equals(other);
public override int GetHashCode()
{

1
src/Avalonia.X11/TransparencyHelper.cs

@ -10,7 +10,6 @@ namespace Avalonia.X11
private readonly X11Globals _globals;
private WindowTransparencyLevel _currentLevel;
private WindowTransparencyLevel _requestedLevel;
private bool _isCompositing;
private bool _blurAtomsAreSet;
public Action<WindowTransparencyLevel> TransparencyLevelChanged { get; set; }

2
src/Avalonia.X11/X11Window.Ime.cs

@ -33,8 +33,6 @@ namespace Avalonia.X11
&& ((int)(style & XIMProperties.XIMStatusNothing) != 0))
{
XPoint spot = default;
XRectangle area = default;
//using var areaS = new Utf8Buffer("area");
using var spotS = new Utf8Buffer("spotLocation");

4
src/Avalonia.X11/X11Window.Xim.cs

@ -112,8 +112,8 @@ namespace Avalonia.X11
public ValueTask<bool> HandleEventAsync(RawKeyEventArgs args, int keyVal, int keyCode) =>
new ValueTask<bool>(false);
public event Action<string> Commit;
public event Action<X11InputMethodForwardedKey> ForwardKey;
public event Action<string> Commit { add { } remove { } }
public event Action<X11InputMethodForwardedKey> ForwardKey { add { } remove { } }
}

9
src/Avalonia.X11/X11Window.cs

@ -30,7 +30,6 @@ namespace Avalonia.X11
ITopLevelImplWithTextInputMethod
{
private readonly AvaloniaX11Platform _platform;
private readonly IWindowImpl _popupParent;
private readonly bool _popup;
private readonly X11Info _x11;
private XConfigureEvent? _configure;
@ -416,7 +415,9 @@ namespace Avalonia.X11
2 => RawPointerEventType.MiddleButtonDown,
3 => RawPointerEventType.RightButtonDown,
8 => RawPointerEventType.XButton1Down,
9 => RawPointerEventType.XButton2Down
9 => RawPointerEventType.XButton2Down,
_ => throw new AvaloniaInternalException(
"No raw event defined for button press event.")
},
ref ev, ev.ButtonEvent.state);
else
@ -444,7 +445,9 @@ namespace Avalonia.X11
2 => RawPointerEventType.MiddleButtonUp,
3 => RawPointerEventType.RightButtonUp,
8 => RawPointerEventType.XButton1Up,
9 => RawPointerEventType.XButton2Up
9 => RawPointerEventType.XButton2Up,
_ => throw new AvaloniaInternalException(
"No raw event defined for button release event.")
},
ref ev, ev.ButtonEvent.state);
}

1
src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs

@ -15,7 +15,6 @@ namespace Avalonia.LinuxFramebuffer
private readonly IOutputBackend _outputBackend;
private readonly IInputBackend _inputBackend;
private bool _renderQueued;
public IInputRoot InputRoot { get; private set; }
public FramebufferToplevelImpl(IOutputBackend outputBackend, IInputBackend inputBackend)

1
src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs

@ -16,7 +16,6 @@ namespace Avalonia.LinuxFramebuffer.Output
public unsafe class DrmOutput : IGlOutputBackend, IGlPlatformSurface
{
private DrmCard _card;
private readonly EglGlPlatformSurface _eglPlatformSurface;
public PixelSize PixelSize => _mode.Resolution;
public double Scaling { get; set; }
public IGlContext PrimaryContext => _deferredContext;

3
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlCompiler.cs

@ -14,7 +14,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
{
class AvaloniaXamlIlCompiler : XamlILCompiler
{
private readonly TransformerConfiguration _configuration;
private readonly IXamlType _contextType;
private readonly AvaloniaXamlIlDesignPropertiesTransformer _designTransformer;
private readonly AvaloniaBindingExtensionTransformer _bindingTransformer;
@ -22,8 +21,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
private AvaloniaXamlIlCompiler(TransformerConfiguration configuration, XamlLanguageEmitMappings<IXamlILEmitter, XamlILNodeEmitResult> emitMappings)
: base(configuration, emitMappings, true)
{
_configuration = configuration;
void InsertAfter<T>(params IXamlAstTransformer[] t)
=> Transformers.InsertRange(Transformers.FindIndex(x => x is T) + 1, t);

71
src/Markup/Avalonia.Markup/Markup/Parsers/PropertyPathGrammar.cs

@ -37,8 +37,8 @@ namespace Avalonia.Markup.Parsers
(state, syntax) = ParseNext(ref r);
else if (state == State.AfterProperty)
(state, syntax) = ParseAfterProperty(ref r);
if (syntax != null)
{
parsed.Add(syntax);
@ -52,16 +52,16 @@ namespace Avalonia.Markup.Parsers
return parsed;
}
private static (State, ISyntax) ParseNext(ref CharacterReader r)
{
r.SkipWhitespace();
if (r.End)
return (State.End, null);
return ParseStart(ref r);
}
private static (State, ISyntax) ParseStart(ref CharacterReader r)
{
if (TryParseCasts(ref r, out var rv))
@ -81,8 +81,8 @@ namespace Avalonia.Markup.Parsers
"Unable to parse qualified property name, expected `(ns:TypeName.PropertyName)` or `(TypeName.PropertyName)` after `(`";
var typeName = ParseXamlIdentifier(ref r);
if (!r.TakeIf('.'))
throw new ExpressionParseException(r.Position, error);
@ -122,7 +122,7 @@ namespace Avalonia.Markup.Parsers
return (null, ident.ToString());
}
private static (State, ISyntax) ParseProperty(ref CharacterReader r)
{
r.SkipWhitespace();
@ -146,20 +146,20 @@ namespace Avalonia.Markup.Parsers
return true;
}
private static (State, ISyntax) ParseAfterProperty(ref CharacterReader r)
{
if (TryParseCasts(ref r, out var rv))
return rv;
r.SkipWhitespace();
if (r.End)
return (State.End, null);
if (r.TakeIf('.'))
return (State.Next, ChildTraversalSyntax.Instance);
throw new ExpressionParseException(r.Position, "Unexpected character " + r.Peek + " after property name");
}
@ -169,7 +169,7 @@ namespace Avalonia.Markup.Parsers
var type = ParseXamlIdentifier(ref r);
return (State.AfterProperty, new EnsureTypeSyntax {TypeName = type.name, TypeNamespace = type.ns});
}
private static (State, ISyntax) ParseCastType(ref CharacterReader r)
{
r.SkipWhitespace();
@ -179,7 +179,7 @@ namespace Avalonia.Markup.Parsers
public interface ISyntax
{
}
public class PropertySyntax : ISyntax
@ -189,8 +189,13 @@ namespace Avalonia.Markup.Parsers
public override bool Equals(object obj)
=> obj is PropertySyntax other
&& other.Name == Name;
public override int GetHashCode()
{
return 539060726 + EqualityComparer<string>.Default.GetHashCode(Name);
}
}
public class TypeQualifiedPropertySyntax : ISyntax
{
public string Name { get; set; }
@ -202,14 +207,28 @@ namespace Avalonia.Markup.Parsers
&& other.Name == Name
&& other.TypeName == TypeName
&& other.TypeNamespace == TypeNamespace;
public override int GetHashCode()
{
int hashCode = 30698940;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TypeName);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TypeNamespace);
return hashCode;
}
}
public class ChildTraversalSyntax : ISyntax
{
public static ChildTraversalSyntax Instance { get; } = new ChildTraversalSyntax();
public override bool Equals(object obj) => obj is ChildTraversalSyntax;
public override int GetHashCode()
{
return base.GetHashCode();
}
}
public class EnsureTypeSyntax : ISyntax
{
public string TypeName { get; set; }
@ -218,8 +237,16 @@ namespace Avalonia.Markup.Parsers
=> obj is EnsureTypeSyntax other
&& other.TypeName == TypeName
&& other.TypeNamespace == TypeNamespace;
public override int GetHashCode()
{
int hashCode = 127780694;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TypeName);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TypeNamespace);
return hashCode;
}
}
public class CastTypeSyntax : ISyntax
{
public string TypeName { get; set; }
@ -228,6 +255,14 @@ namespace Avalonia.Markup.Parsers
=> obj is CastTypeSyntax other
&& other.TypeName == TypeName
&& other.TypeNamespace == TypeNamespace;
public override int GetHashCode()
{
int hashCode = 127780694;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TypeName);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TypeNamespace);
return hashCode;
}
}
}
}

1
src/Skia/Avalonia.Skia/Gpu/ISkiaGpu.cs

@ -21,6 +21,7 @@ namespace Avalonia.Skia
/// Creates an offscreen render target surface
/// </summary>
/// <param name="size">size in pixels</param>
/// <param name="session">An optional custom render session.</param>
ISkiaSurface TryCreateSurface(PixelSize size, ISkiaGpuRenderSession session);
}

2
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaGpu.cs

@ -66,7 +66,7 @@ namespace Avalonia.Skia
_canCreateSurfaces = true;
return surface;
}
catch (Exception e)
catch (Exception)
{
Logger.TryGet(LogEventLevel.Error, "OpenGL")
?.Log(this, "Unable to create a Skia-compatible FBO manually");

1
src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs

@ -150,6 +150,7 @@ namespace Avalonia.Win32.Interop.Wpf
if (_image == null || _oldDpi.X != dpi.X || _oldDpi.Y != dpi.Y)
{
_image = new D3DImage(dpi.X, dpi.Y);
_oldDpi = dpi;
}
_impl.ImageSource = _image;

1
src/Windows/Avalonia.Win32/WinRT/Composition/WinUICompositorConnection.cs

@ -17,7 +17,6 @@ namespace Avalonia.Win32.WinRT.Composition
class WinUICompositorConnection : IRenderTimer
{
private readonly EglContext _syncContext;
private IntPtr _queue;
private ICompositor _compositor;
private ICompositor2 _compositor2;
private ICompositor5 _compositor5;

9
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -171,9 +171,12 @@ namespace Avalonia.Win32
WindowsMessage.WM_XBUTTONDOWN =>
HighWord(ToInt32(wParam)) == 1 ?
RawPointerEventType.XButton1Down :
RawPointerEventType.XButton2Down
RawPointerEventType.XButton2Down,
_ => throw new AvaloniaInternalException(
"No raw event defined for button down message.")
},
DipFromLParam(lParam), GetMouseModifiers(wParam));
;
break;
}
@ -201,6 +204,8 @@ namespace Avalonia.Win32
HighWord(ToInt32(wParam)) == 1 ?
RawPointerEventType.XButton1Up :
RawPointerEventType.XButton2Up,
_ => throw new AvaloniaInternalException(
"No raw event defined for button up message.")
},
DipFromLParam(lParam), GetMouseModifiers(wParam));
break;
@ -293,6 +298,8 @@ namespace Avalonia.Win32
HighWord(ToInt32(wParam)) == 1 ?
RawPointerEventType.XButton1Down :
RawPointerEventType.XButton2Down,
_ => throw new AvaloniaInternalException(
"No raw event defined for button down message.")
},
PointToClient(PointFromLParam(lParam)), GetMouseModifiers(wParam));
break;

2
src/tools/MicroComGenerator/CSharpGen.Utils.cs

@ -40,7 +40,7 @@ namespace MicroComGenerator
SyntaxToken Semicolon() => Token(SyntaxKind.SemicolonToken);
static VariableDeclarationSyntax DeclareVar(string type, string name,
ExpressionSyntax? initializer = null)
ExpressionSyntax initializer = null)
=> VariableDeclaration(ParseTypeName(type),
SingletonSeparatedList(VariableDeclarator(name)
.WithInitializer(initializer == null ? null : EqualsValueClause(initializer))));

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

@ -1066,7 +1066,7 @@ namespace Avalonia.Controls.UnitTests
[Fact]
public void Auto_Expanding_In_Style_Should_Not_Break_Range_Selection()
{
/// Issue #2980.
// Issue #2980.
using (Application())
{
var target = new DerivedTreeView

Loading…
Cancel
Save