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

fixes: some null annotation #6754

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
82729a1
fixes: some null annotation
workgroupengineering Oct 18, 2021
c1c5289
Merge branch 'master' into fixes/Some_Null_Annotation_And_Warning
workgroupengineering Oct 19, 2021
0309dda
fixes: Replace CS8600 warning suppression with null-forgiving operator
workgroupengineering Oct 19, 2021
a828e5b
fixes: MenuFlyout Possible null reference argument for parameter
workgroupengineering Oct 19, 2021
895fd71
fixes: ConstantValueEntry Possible null reference argument for parameter
workgroupengineering Oct 19, 2021
2264402
fixes: ValueStore Possible null reference argument for parameter
workgroupengineering Oct 19, 2021
c859f57
Merge branch 'master' into fixes/Some_Null_Annotation_And_Warning
workgroupengineering Oct 23, 2021
97a920d
Review suggestions apply
workgroupengineering Oct 23, 2021
44225c6
fixes: Revert the fix, because the fix throw error CS8627 on Linux an…
workgroupengineering Oct 23, 2021
9014a03
Merge branch 'master' into fixes/Some_Null_Annotation_And_Warning
workgroupengineering Oct 28, 2021
67e5962
fix(TrayIcon): CommandParameter alow null
workgroupengineering Oct 28, 2021
94eeb7d
restore fix
workgroupengineering Oct 28, 2021
d1b325e
Merge branch 'master' into fixes/Some_Null_Annotation_And_Warning
workgroupengineering Nov 12, 2021
0624a1d
fixes: Mark FocusManager and InputManager as nullable
workgroupengineering Nov 15, 2021
269610b
Merge branch 'master' into fixes/Some_Null_Annotation_And_Warning
workgroupengineering Nov 22, 2021
72fd5f0
fixes: PropertySetterInstance
workgroupengineering Nov 22, 2021
2e92a87
Merge branch 'master' into fixes/Some_Null_Annotation_And_Warning
workgroupengineering Nov 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Data/BindingValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static BindingValue<T> FromUntyped(object? value)
UnsetValueType _ => Unset,
DoNothingType _ => DoNothing,
BindingNotification n => n.ToBindingValue().Cast<T>(),
_ => new BindingValue<T>((T)value)
_ => new BindingValue<T>((T?)value)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static Func<object, bool> CreateCanExecute(object target
.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
Expand Down
6 changes: 3 additions & 3 deletions src/Avalonia.Controls/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static Application Current
/// <value>
/// The application's focus manager.
/// </value>
public IFocusManager FocusManager
public IFocusManager? FocusManager
{
get;
private set;
Expand All @@ -116,7 +116,7 @@ public IFocusManager FocusManager
/// <value>
/// The application's input manager.
/// </value>
public InputManager InputManager
public InputManager? InputManager
{
get;
private set;
Expand Down Expand Up @@ -175,7 +175,7 @@ public IResourceDictionary Resources
/// - <see cref="ISingleViewApplicationLifetime"/>
/// - <see cref="IControlledApplicationLifetime"/>
/// </summary>
public IApplicationLifetime ApplicationLifetime { get; set; }
public IApplicationLifetime? ApplicationLifetime { get; set; }

event Action<IReadOnlyList<IStyle>> IGlobalStyles.GlobalStylesAdded
{
Expand Down
6 changes: 5 additions & 1 deletion src/Avalonia.Controls/Flyouts/FlyoutBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,12 @@ private bool CancelOpening()
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--)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Avalonia.Controls/Primitives/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public class Popup : Control, IVisualTreeHost, IPopupHostProvider
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 @@ -138,7 +138,7 @@ public class Popup : Control, IVisualTreeHost, IPopupHostProvider
private bool _isOpen;
private bool _ignoreIsOpenChanged;
private PopupOpenState? _openState;
private IInputElement _overlayInputPassThroughElement;
private IInputElement? _overlayInputPassThroughElement;
private Action<IPopupHost?>? _popupHostChangedHandler;

/// <summary>
Expand Down Expand Up @@ -310,7 +310,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
10 changes: 5 additions & 5 deletions src/Avalonia.Controls/SplitView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ Pseudo classes & combos
/// <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 =
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved
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 =
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved
AvaloniaProperty.Register<HeaderedContentControl, IDataTemplate>(nameof(PaneTemplate));

/// <summary>
/// Defines the <see cref="UseLightDismissOverlayMode"/> property
Expand Down Expand Up @@ -267,7 +267,7 @@ public object Pane
/// <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);
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/TrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public ICommand? Command
/// 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); }
Expand Down
6 changes: 3 additions & 3 deletions src/Avalonia.Input/ICommandSource.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Windows.Input;

#nullable enable
namespace Avalonia.Input
{
///<summary>
Expand All @@ -12,13 +12,13 @@ public interface ICommandSource
/// 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>
Expand Down
6 changes: 3 additions & 3 deletions src/Avalonia.Styling/Styling/PropertySetterInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ internal class PropertySetterInstance<T> : SingleSubscriberObservableBase<Bindin
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;
Expand Down Expand Up @@ -57,7 +57,7 @@ public void Start(bool hasActivator)
{
if (_styledProperty is object)
{
_subscription = _target.SetValue(_styledProperty, _value, BindingPriority.Style);
_subscription = _target.SetValue(_styledProperty!, _value, BindingPriority.Style);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Styling/Styling/Setter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void IAvaloniaPropertyVisitor<SetterVisitorData>.Visit<T>(
data.result = new PropertySetterInstance<T>(
data.target,
property,
(T)data.value);
(T?)data.value);
}
}

Expand All @@ -128,7 +128,7 @@ void IAvaloniaPropertyVisitor<SetterVisitorData>.Visit<T>(
data.result = new PropertySetterInstance<T>(
data.target,
property,
(T)data.value);
(T)data.value!);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/MicroComGenerator/CSharpGen.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ string Format(CompilationUnitSyntax unit)
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))));
Expand Down