Browse Source

Merge pull request #6754 from workgroupengineering/fixes/Some_Null_Annotation_And_Warning

fixes: some null annotation
pull/7003/head
Max Katz 5 years ago
committed by GitHub
parent
commit
4f31cfc365
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Base/Data/BindingValue.cs
  2. 2
      src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs
  3. 6
      src/Avalonia.Controls/Application.cs
  4. 6
      src/Avalonia.Controls/Flyouts/FlyoutBase.cs
  5. 8
      src/Avalonia.Controls/Primitives/Popup.cs
  6. 10
      src/Avalonia.Controls/SplitView.cs
  7. 2
      src/Avalonia.Controls/TrayIcon.cs
  8. 6
      src/Avalonia.Input/ICommandSource.cs
  9. 6
      src/Avalonia.Styling/Styling/PropertySetterInstance.cs
  10. 4
      src/Avalonia.Styling/Styling/Setter.cs
  11. 2
      src/tools/MicroComGenerator/CSharpGen.Utils.cs

2
src/Avalonia.Base/Data/BindingValue.cs

@ -247,7 +247,7 @@ namespace Avalonia.Data
UnsetValueType _ => Unset,
DoNothingType _ => DoNothing,
BindingNotification n => n.ToBindingValue().Cast<T>(),
_ => new BindingValue<T>((T)value)
_ => new BindingValue<T>((T?)value)
};
}

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

@ -161,7 +161,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

6
src/Avalonia.Controls/Application.cs

@ -104,7 +104,7 @@ namespace Avalonia
/// <value>
/// The application's focus manager.
/// </value>
public IFocusManager FocusManager
public IFocusManager? FocusManager
{
get;
private set;
@ -116,7 +116,7 @@ namespace Avalonia
/// <value>
/// The application's input manager.
/// </value>
public InputManager InputManager
public InputManager? InputManager
{
get;
private set;
@ -175,7 +175,7 @@ namespace Avalonia
/// - <see cref="ISingleViewApplicationLifetime"/>
/// - <see cref="IControlledApplicationLifetime"/>
/// </summary>
public IApplicationLifetime ApplicationLifetime { get; set; }
public IApplicationLifetime? ApplicationLifetime { get; set; }
event Action<IReadOnlyList<IStyle>> IGlobalStyles.GlobalStylesAdded
{

6
src/Avalonia.Controls/Flyouts/FlyoutBase.cs

@ -562,8 +562,12 @@ namespace Avalonia.Controls.Primitives
return eventArgs.Cancel;
}
internal static void SetPresenterClasses(IControl presenter, Classes classes)
internal static void SetPresenterClasses(IControl? presenter, Classes classes)
{
if(presenter is null)
{
return;
}
//Remove any classes no longer in use, ignoring pseudo classes
for (int i = presenter.Classes.Count - 1; i >= 0; i--)
{

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

@ -93,8 +93,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);
@ -138,7 +138,7 @@ namespace Avalonia.Controls.Primitives
private bool _isOpen;
private bool _ignoreIsOpenChanged;
private PopupOpenState? _openState;
private IInputElement _overlayInputPassThroughElement;
private IInputElement? _overlayInputPassThroughElement;
private Action<IPopupHost?>? _popupHostChangedHandler;
/// <summary>
@ -310,7 +310,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);

10
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="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);

2
src/Avalonia.Controls/TrayIcon.cs

@ -140,7 +140,7 @@ namespace Avalonia.Controls
/// Gets or sets the parameter to pass to the <see cref="Command"/> property of a
/// <see cref="TrayIcon"/>.
/// </summary>
public object CommandParameter
public object? CommandParameter
{
get { return GetValue(CommandParameterProperty); }
set { SetValue(CommandParameterProperty, value); }

6
src/Avalonia.Input/ICommandSource.cs

@ -1,5 +1,5 @@
using System.Windows.Input;
#nullable enable
namespace Avalonia.Input
{
///<summary>
@ -12,13 +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>

6
src/Avalonia.Styling/Styling/PropertySetterInstance.cs

@ -16,14 +16,14 @@ namespace Avalonia.Styling
private readonly IStyleable _target;
private readonly StyledPropertyBase<T>? _styledProperty;
private readonly DirectPropertyBase<T>? _directProperty;
private readonly T _value;
private readonly T? _value;
private IDisposable? _subscription;
private bool _isActive;
public PropertySetterInstance(
IStyleable target,
StyledPropertyBase<T> property,
T value)
T? value)
{
_target = target;
_styledProperty = property;
@ -57,7 +57,7 @@ namespace Avalonia.Styling
{
if (_styledProperty is object)
{
_subscription = _target.SetValue(_styledProperty, _value, BindingPriority.Style);
_subscription = _target.SetValue(_styledProperty!, _value, BindingPriority.Style);
}
else
{

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

@ -101,7 +101,7 @@ namespace Avalonia.Styling
data.result = new PropertySetterInstance<T>(
data.target,
property,
(T)data.value);
(T?)data.value);
}
}
@ -128,7 +128,7 @@ namespace Avalonia.Styling
data.result = new PropertySetterInstance<T>(
data.target,
property,
(T)data.value);
(T)data.value!);
}
}

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

Loading…
Cancel
Save