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 1 commit
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: 2 additions & 0 deletions src/Avalonia.Base/Data/BindingValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ public static BindingValue<T> FromUntyped(object? value)
UnsetValueType _ => Unset,
DoNothingType _ => DoNothing,
BindingNotification n => n.ToBindingValue().Cast<T>(),
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
_ => new BindingValue<T>((T)value)
workgroupengineering marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,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
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/Application.cs
Original file line number Diff line number Diff line change
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
8 changes: 4 additions & 4 deletions src/Avalonia.Controls/Primitives/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,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 @@ -136,7 +136,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 @@ -308,7 +308,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
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
8 changes: 8 additions & 0 deletions src/Avalonia.Styling/Styling/Setter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ void IAvaloniaPropertyVisitor<SetterVisitorData>.Visit<T>(
data.result = new PropertySetterInstance<T>(
data.target,
property,
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
#pragma warning disable CS8604 // Possible null reference argument.
(T)data.value);
#pragma warning restore CS8604 // Possible null reference argument.
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
}
}

Expand All @@ -128,7 +132,11 @@ void IAvaloniaPropertyVisitor<SetterVisitorData>.Visit<T>(
data.result = new PropertySetterInstance<T>(
data.target,
property,
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
#pragma warning disable CS8604 // Possible null reference argument.
(T)data.value);
#pragma warning restore CS8604 // Possible null reference argument.
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
}
}

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