Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features zerowarnings: Changes which alter code and could affect functionality in the base library #4882

Closed
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8768879
Null Annotation
workgroupengineering Oct 17, 2020
89984ad
suppress warning CS0618
workgroupengineering Oct 17, 2020
208d8ee
suppress warning CS0067
workgroupengineering Oct 17, 2020
c4821e3
fixes field defined but never used
workgroupengineering Oct 17, 2020
8ae1bc3
fixes CS0675
workgroupengineering Oct 17, 2020
d77691f
suppres warning CS4014
workgroupengineering Oct 17, 2020
44fe0ac
suppres warning CS8509
workgroupengineering Oct 17, 2020
7b8a888
fixes CS0659
workgroupengineering Oct 17, 2020
1f64c25
Hide to intellisense obsolete
workgroupengineering Oct 17, 2020
111b544
Remove event Tick in never used
workgroupengineering Oct 17, 2020
b234299
fixes CS0642
workgroupengineering Oct 17, 2020
98311e9
fixes warning CS0108
workgroupengineering Oct 17, 2020
fff3e6c
ConsoleView.xaml.cs : Replace CS4014 warning disable CS4014 with _
workgroupengineering Oct 19, 2020
1a650e1
X11IconLoader: replace warning disable CS0618 with WriteableBitmap ov…
workgroupengineering Oct 19, 2020
8444fa4
HeadlessWindowImpl.cs : Remove WriteableBitmap warning disable CS0618
workgroupengineering Oct 19, 2020
6da4330
public new T MethodName instead of new public T
workgroupengineering Oct 19, 2020
733f3ea
Application.cs(158,29): warning CS8632: The annotation for nullable r…
workgroupengineering Oct 19, 2020
5a16ea9
ProgressBar.cs(220,21): warning CS0618: IndeterminateStartingOffset a…
workgroupengineering Oct 19, 2020
e3a1132
TextBox.cs(540,27): warning CS1998: This async method lacks 'await' o…
workgroupengineering Oct 19, 2020
32ba09a
TextBox.cs(840,25): warning CS0618: 'PointerPressedEventArgs.ClickCou…
workgroupengineering Oct 19, 2020
834f233
Menu.cs(20,43): warning CS0169: The field 'Menu._overlay' is never used
workgroupengineering Oct 19, 2020
21b1444
Grid.cs(986,22): warning CS1573: Parameter 'hasDesiredSizeUChanged' h…
workgroupengineering Oct 19, 2020
4354147
GlSkiaGpu.cs(69,30): warning CS0168: The variable 'e' is declared but…
workgroupengineering Oct 19, 2020
535738a
Update Log message
workgroupengineering Oct 19, 2020
7040a3e
suppress: MouseDevice.cs(78,65): warning CS0618: 'MouseDevice.Positio…
workgroupengineering Oct 27, 2020
bd1ff64
SplitView Nullable Annoation
workgroupengineering Oct 27, 2020
5fccefa
ISkiaGpu.cs(24,77): warning CS1573: Parameter 'session' has no matchi…
workgroupengineering Oct 27, 2020
e9efa57
fixes CSharpGen.Utils.cs(43,29): warning CS8632: The annotation for n…
workgroupengineering Nov 2, 2020
795b331
fixes: warning CS1587 XML comment is not placed on a valid language e…
workgroupengineering Jan 20, 2021
195316b
fixes Vector.cs warning CS8765 Nullability of type of parameter 'obj…
workgroupengineering Jan 20, 2021
01507eb
fixes MenuItem warning CS8766 Nullability of reference types in retur…
workgroupengineering Jan 20, 2021
fe4325b
fixes ValueStore nullable type annotation
workgroupengineering Jan 20, 2021
ffddefb
fixes warning CS0169: The field 'WinUICompositorConnection._queue' is…
workgroupengineering Jan 20, 2021
ed65194
fixes warning CS0219: The variable 'area' is assigned but its value i…
workgroupengineering Jan 20, 2021
3916b62
suppress Warning CS0618 'MouseDevice.Captured' is obsolete: 'Use IPoi…
workgroupengineering Jan 20, 2021
cd975b0
Android mark obsolete Invalidate methods overload
workgroupengineering Jan 20, 2021
91f9389
fixes Warning CS8002 Referenced assembly 'MonoMac, Version=0.0.4.0, C…
workgroupengineering Jan 20, 2021
6d1719a
Merge branch 'master' into features/zerowarnings_core
workgroupengineering Jan 22, 2021
5cc5b30
Merge branch 'master' into features/zerowarnings_core
workgroupengineering Jan 23, 2021
dadc2ed
Add MethodToCommandConverter nullable annotation
workgroupengineering Jan 23, 2021
c84e4a3
Merge branch 'master' into features/zerowarnings_core
workgroupengineering Jan 27, 2021
efd9578
Merge branch 'master' into features/zerowarnings_core
workgroupengineering Feb 1, 2021
d82f35d
Merge branch 'master' into features/zerowarnings_core
workgroupengineering Feb 3, 2021
41d36c9
Merge branch 'features/zerowarnings_core' of https://github.com/workg…
workgroupengineering Feb 5, 2021
8a4860c
Revert "Add MethodToCommandConverter nullable annotation"
workgroupengineering Feb 5, 2021
815d6f9
fixes ValueStore nullable type annotation
workgroupengineering Feb 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/interop/NativeEmbedSample/NativeEmbedSample.csproj
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

<ItemGroup>
Expand Down
Expand Up @@ -43,11 +43,13 @@ public override void Invalidate()
}
}

[Obsolete]
public override void Invalidate(global::Android.Graphics.Rect dirty)
{
Invalidate();
}

[Obsolete]
public override void Invalidate(int l, int t, int r, int b)
{
Invalidate();
Expand Down
Expand Up @@ -86,7 +86,9 @@ public AndroidTouchEventsHelper(TView view, Func<IInputRoot> getInputRoot, Func<
mouseEventType.Value, _point, RawInputModifiers.LeftMouseButton);
_view.Input(mouseEvent);

#pragma warning disable CS0618 // Type or member is obsolete
if (e.Action == MotionEventActions.Move && mouseDevice.Captured == null)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (_lastTouchMovePoint != null)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Avalonia.Base/Data/BindingValue.cs
Expand Up @@ -246,7 +246,9 @@ public static BindingValue<T> FromUntyped(object? value)
UnsetValueType _ => Unset,
DoNothingType _ => DoNothing,
BindingNotification n => n.ToBindingValue().Cast<T>(),
#pragma warning disable CS8601
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved
_ => new BindingValue<T>((T)value)
#pragma warning restore CS8601
};
}

Expand Down
17 changes: 10 additions & 7 deletions src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs
@@ -1,12 +1,13 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Windows.Input;
using Avalonia.Utilities;

#nullable enable
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved
namespace Avalonia.Data.Converters
{
class MethodToCommandConverter : ICommand
Expand All @@ -18,11 +19,11 @@ class MethodToCommandConverter : ICommand
.GetProperty(nameof(CultureInfo.CurrentCulture), BindingFlags.Public | BindingFlags.Static);
readonly Func<object, bool> canExecute;
readonly Action<object> execute;
readonly WeakPropertyChangedProxy weakPropertyChanged;
readonly PropertyChangedEventHandler propertyChangedEventHandler;
readonly string[] dependencyProperties;
readonly WeakPropertyChangedProxy? weakPropertyChanged;
readonly PropertyChangedEventHandler? propertyChangedEventHandler;
readonly string[]? dependencyProperties;

public MethodToCommandConverter(Delegate action)
public MethodToCommandConverter([DisallowNull] Delegate action)
{
var target = action.Target;
var canExecuteMethodName = "Can" + action.Method.Name;
Expand Down Expand Up @@ -74,7 +75,7 @@ void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
}

#pragma warning disable 0067
public event EventHandler CanExecuteChanged;
public event EventHandler? CanExecuteChanged;
#pragma warning restore 0067

public bool CanExecute(object parameter) => canExecute(parameter);
Expand Down Expand Up @@ -140,7 +141,7 @@ void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
);

}
Action<object> action = null;
Action<object> action;
try
{
action = Expression
Expand Down Expand Up @@ -173,6 +174,7 @@ void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
private static Expression? ConvertTarget(object? target, MethodInfo method) =>
target is null ? null : Expression.Convert(Expression.Constant(target), method.DeclaringType);

#nullable disable
internal class WeakPropertyChangedProxy
{
readonly WeakReference<PropertyChangedEventHandler> _listener = new WeakReference<PropertyChangedEventHandler>(null);
Expand Down Expand Up @@ -215,5 +217,6 @@ void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
}

}
#nullable restore
}
}
12 changes: 6 additions & 6 deletions src/Avalonia.Base/ValueStore.cs
Expand Up @@ -37,7 +37,7 @@ public bool IsAnimating(AvaloniaProperty property)
{
if (_values.TryGetValue(property, out var slot))
{
return slot.Priority < BindingPriority.LocalValue;
return slot?.Priority < BindingPriority.LocalValue;
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved
}

return false;
Expand All @@ -47,7 +47,7 @@ public bool IsSet(AvaloniaProperty property)
{
if (_values.TryGetValue(property, out var slot))
{
return slot.GetValue().HasValue;
return slot?.GetValue().HasValue == true;
}

return false;
Expand All @@ -58,7 +58,7 @@ public bool IsSet(AvaloniaProperty property)
BindingPriority maxPriority,
out T value)
{
if (_values.TryGetValue(property, out var slot))
if (_values.TryGetValue(property, out var slot) && slot != null)
{
var v = ((IValue<T>)slot).GetValue(maxPriority);

Expand All @@ -82,7 +82,7 @@ public bool IsSet(AvaloniaProperty property)

IDisposable? result = null;

if (_values.TryGetValue(property, out var slot))
if (_values.TryGetValue(property, out var slot) && slot != null)
{
result = SetExisting(slot, property, value, priority);
}
Expand Down Expand Up @@ -119,7 +119,7 @@ public bool IsSet(AvaloniaProperty property)
IObservable<BindingValue<T>> source,
BindingPriority priority)
{
if (_values.TryGetValue(property, out var slot))
if (_values.TryGetValue(property, out var slot) && slot != null)
{
return BindExisting(slot, property, source, priority);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ public void CoerceValue<T>(StyledPropertyBase<T> property)

public Diagnostics.AvaloniaPropertyValue? GetDiagnostic(AvaloniaProperty property)
{
if (_values.TryGetValue(property, out var slot))
if (_values.TryGetValue(property, out var slot) && slot != null)
{
var slotValue = slot.GetValue();
return new Diagnostics.AvaloniaPropertyValue(
Expand Down
Expand Up @@ -58,7 +58,6 @@ public class DataGridPathGroupDescription : DataGridGroupDescription
{
private string _propertyPath;
private Type _propertyType;
private IValueConverter _valueConverter;
private StringComparison _stringComparison = StringComparison.Ordinal;

public DataGridPathGroupDescription(string propertyPath)
Expand All @@ -83,8 +82,8 @@ object GetKey(object o)
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;
}
Expand All @@ -99,6 +98,8 @@ public override bool KeysMatch(object groupKey, object itemKey)
}
public override string PropertyName => _propertyPath;

public IValueConverter ValueConverter { get; set; }

private Type GetPropertyType(object o)
{
return o.GetType().GetNestedPropertyType(_propertyPath);
Expand Down
4 changes: 0 additions & 4 deletions src/Avalonia.Controls.DataGrid/DataGrid.cs
Expand Up @@ -74,8 +74,6 @@ public partial class DataGrid : TemplatedControl
internal const double DATAGRID_defaultRowGroupSublevelIndent = 20;
private const double DATAGRID_defaultMinColumnWidth = 20;
private const double DATAGRID_defaultMaxColumnWidth = double.PositiveInfinity;

private List<Exception> _validationErrors;
private List<Exception> _bindingValidationErrors;
private IDisposable _validationSubscription;

Expand All @@ -102,7 +100,6 @@ public partial class DataGrid : TemplatedControl
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
Expand Down Expand Up @@ -141,7 +138,6 @@ public partial class DataGrid : TemplatedControl
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
Expand Down
7 changes: 1 addition & 6 deletions src/Avalonia.Controls.DataGrid/Utils/CellEditBinding.cs
Expand Up @@ -57,7 +57,6 @@ class SubjectWrapper : LightweightObservableBase<object>, ISubject<object>, IDis
private IDisposable _subscription;
private object _controlValue;
private bool _isControlValueSet = false;
private bool _settingSourceValue = false;

public SubjectWrapper(ISubject<object> bindingSourceSubject, CellEditBinding editBinding)
{
Expand All @@ -67,11 +66,7 @@ public SubjectWrapper(ISubject<object> bindingSourceSubject, CellEditBinding edi

private void SetSourceValue(object value)
{
_settingSourceValue = true;

_sourceSubject.OnNext(value);

_settingSourceValue = false;
}
private void SetControlValue(object value)
{
Expand Down Expand Up @@ -157,4 +152,4 @@ public void CommitEdit()
}
}
}
}
}
4 changes: 4 additions & 0 deletions src/Avalonia.Controls/ApiCompatBaseline.txt
@@ -0,0 +1,4 @@
Compat issues with assembly Avalonia.Controls:
MembersMustExist : Member 'public void Avalonia.Controls.Platform.InternalPlatformThreadingInterface.add_Tick(System.Action<System.TimeSpan>)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public void Avalonia.Controls.Platform.InternalPlatformThreadingInterface.remove_Tick(System.Action<System.TimeSpan>)' does not exist in the implementation but it does exist in the contract.
Total Issues: 2
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/Application.cs
Expand Up @@ -155,7 +155,7 @@ public IResourceDictionary Resources

/// <inheritdoc/>
bool IResourceNode.HasResources => (_resources?.HasResources ?? false) ||
(((IResourceNode?)_styles)?.HasResources ?? false);
((_styles as IResourceNode)?.HasResources ?? false);
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Gets the styling parent of the application, which is null.
Expand Down
2 changes: 2 additions & 0 deletions src/Avalonia.Controls/Border.cs
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/Avalonia.Controls/DrawingPresenter.cs
Expand Up @@ -6,6 +6,8 @@
namespace Avalonia.Controls
{
[Obsolete("Use Image control with DrawingImage source")]
[System.ComponentModel.Browsable(false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public class DrawingPresenter : Control
{
static DrawingPresenter()
Expand Down
1 change: 1 addition & 0 deletions src/Avalonia.Controls/Grid.cs
Expand Up @@ -978,6 +978,7 @@ private void ApplyCachedMinSizes(double[] minSizes, bool isRows)
/// 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 "true" desidere size is changed.</param>
private void MeasureCellsGroup(
int cellsHead,
Size referenceSize,
Expand Down
2 changes: 0 additions & 2 deletions src/Avalonia.Controls/Menu.cs
Expand Up @@ -17,8 +17,6 @@ public class Menu : MenuBase, IMainMenu
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>
Expand Down
@@ -1,10 +1,7 @@
using System;
maxkatz6 marked this conversation as resolved.
Show resolved Hide resolved
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Platform;
using Avalonia.Rendering;
using Avalonia.Threading;

namespace Avalonia.Controls.Platform
Expand Down Expand Up @@ -83,7 +80,5 @@ public void Signal(DispatcherPriority prio)

public bool CurrentThreadIsLoopThread => TlsCurrentThreadIsLoopThread;
public event Action<DispatcherPriority?> Signaled;
public event Action<TimeSpan> Tick;

}
}
8 changes: 4 additions & 4 deletions src/Avalonia.Controls/Primitives/Popup.cs
Expand Up @@ -87,8 +87,8 @@ public class Popup : Control, IVisualTreeHost
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);
Expand Down Expand Up @@ -132,7 +132,7 @@ public class Popup : Control, IVisualTreeHost
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.
Expand Down Expand Up @@ -299,7 +299,7 @@ public bool OverlayDismissEventPassThrough
/// 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);
Expand Down
Expand Up @@ -448,8 +448,10 @@ static class PopupPositionerExtensions
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)
Expand Down
4 changes: 4 additions & 0 deletions src/Avalonia.Controls/Primitives/TemplatedControl.cs
Expand Up @@ -265,7 +265,9 @@ public sealed override void ApplyTemplate()

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);
}

Expand Down Expand Up @@ -333,6 +335,8 @@ protected virtual void OnApplyTemplate(TemplateAppliedEventArgs e)
/// </summary>
/// <param name="e">The event args.</param>
[Obsolete("Use OnApplyTemplate")]
[System.ComponentModel.Browsable(false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
protected virtual void OnTemplateApplied(TemplateAppliedEventArgs e)
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/Avalonia.Controls/ProgressBar.cs
Expand Up @@ -217,8 +217,10 @@ private void UpdateIndicator(Size bounds)
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(
Expand Down
7 changes: 1 addition & 6 deletions 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
Expand All @@ -15,9 +13,6 @@ class EmbeddableRemoteServerTopLevelImpl : RemoteServerTopLevelImpl
public EmbeddableRemoteServerTopLevelImpl(IAvaloniaRemoteTransportConnection transport) : base(transport)
{
}
#pragma warning disable 67
public Action LostFocus { get; set; }

}

public RemoteServer(IAvaloniaRemoteTransportConnection transport)
Expand Down