diff --git a/samples/MiniMvvm/MiniCommand.cs b/samples/MiniMvvm/MiniCommand.cs index c6a9273c20..b39ceced3d 100644 --- a/samples/MiniMvvm/MiniCommand.cs +++ b/samples/MiniMvvm/MiniCommand.cs @@ -6,10 +6,10 @@ namespace MiniMvvm { public sealed class MiniCommand : MiniCommand, ICommand { - private readonly Action _cb; + private readonly Action? _cb; + private readonly Func? _acb; private bool _busy; - private Func _acb; - + public MiniCommand(Action cb) { _cb = cb; @@ -31,10 +31,11 @@ namespace MiniMvvm } - public override event EventHandler CanExecuteChanged; - public override bool CanExecute(object parameter) => !_busy; + public override event EventHandler? CanExecuteChanged; + + public override bool CanExecute(object? parameter) => !_busy; - public override async void Execute(object parameter) + public override async void Execute(object? parameter) { if(Busy) return; @@ -42,9 +43,9 @@ namespace MiniMvvm { Busy = true; if (_cb != null) - _cb((T)parameter); + _cb((T)parameter!); else - await _acb((T)parameter); + await _acb!((T)parameter!); } finally { diff --git a/samples/MiniMvvm/MiniMvvm.csproj b/samples/MiniMvvm/MiniMvvm.csproj index 2a9164624a..1f3869a2b5 100644 --- a/samples/MiniMvvm/MiniMvvm.csproj +++ b/samples/MiniMvvm/MiniMvvm.csproj @@ -1,8 +1,16 @@ + netstandard2.0 + enable + - + + + + + + diff --git a/samples/MiniMvvm/ViewModelBase.cs b/samples/MiniMvvm/ViewModelBase.cs index 8bc398607f..1b2f3b2c1b 100644 --- a/samples/MiniMvvm/ViewModelBase.cs +++ b/samples/MiniMvvm/ViewModelBase.cs @@ -6,8 +6,9 @@ namespace MiniMvvm { public class ViewModelBase : INotifyPropertyChanged { - public event PropertyChangedEventHandler PropertyChanged; - protected bool RaiseAndSetIfChanged(ref T field, T value, [CallerMemberName] string propertyName = null) + public event PropertyChangedEventHandler? PropertyChanged; + + protected bool RaiseAndSetIfChanged(ref T field, T value, [CallerMemberName] string? propertyName = null) { if (!EqualityComparer.Default.Equals(field, value)) { @@ -17,9 +18,8 @@ namespace MiniMvvm } return false; } - - - protected void RaisePropertyChanged([CallerMemberName] string propertyName = null) + + protected void RaisePropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } diff --git a/src/Avalonia.Base/Avalonia.Base.csproj b/src/Avalonia.Base/Avalonia.Base.csproj index 1dbfe9fd8e..d57d7fe2e0 100644 --- a/src/Avalonia.Base/Avalonia.Base.csproj +++ b/src/Avalonia.Base/Avalonia.Base.csproj @@ -57,8 +57,6 @@ - -