added stylecop (#1933)

* added stylecop

* removed xml documentation

* used common stylecop file
This commit is contained in:
Lavius Motileng
2020-04-07 10:19:14 -07:00
parent 89b44f5126
commit cea6b7067a
53 changed files with 626 additions and 536 deletions

View File

@@ -1,7 +1,9 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml;
namespace Microsoft.PowerToys.Settings.UI.Helpers

View File

@@ -16,9 +16,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
}
storage = value;
OnPropertyChanged(propertyName);
this.OnPropertyChanged(propertyName);
}
protected void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected void OnPropertyChanged(string propertyName) => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

View File

@@ -5,9 +5,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
{
public class RelayCommand : ICommand
{
private readonly Action _execute;
private readonly Action execute;
private readonly Func<bool> _canExecute;
private readonly Func<bool> canExecute;
public event EventHandler CanExecuteChanged;
@@ -18,22 +18,22 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
public RelayCommand(Action execute, Func<bool> canExecute)
{
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
}
public bool CanExecute(object parameter) => _canExecute == null || _canExecute();
public bool CanExecute(object parameter) => this.canExecute == null || this.canExecute();
public void Execute(object parameter) => _execute();
public void Execute(object parameter) => this.execute();
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
public void OnCanExecuteChanged() => this.CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
public class RelayCommand<T> : ICommand
{
private readonly Action<T> _execute;
private readonly Action<T> execute;
private readonly Func<T, bool> _canExecute;
private readonly Func<T, bool> canExecute;
public event EventHandler CanExecuteChanged;
@@ -44,14 +44,14 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
public RelayCommand(Action<T> execute, Func<T, bool> canExecute)
{
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
}
public bool CanExecute(object parameter) => _canExecute == null || _canExecute((T)parameter);
public bool CanExecute(object parameter) => this.canExecute == null || this.canExecute((T)parameter);
public void Execute(object parameter) => _execute((T)parameter);
public void Execute(object parameter) => this.execute((T)parameter);
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
public void OnCanExecuteChanged() => this.CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}

View File

@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using Windows.ApplicationModel.Resources;
@@ -7,11 +11,11 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
{
internal static class ResourceExtensions
{
private static ResourceLoader _resLoader = new ResourceLoader();
private static readonly ResourceLoader ResLoader = new ResourceLoader();
public static string GetLocalized(this string resourceKey)
{
return _resLoader.GetString(resourceKey);
return ResLoader.GetString(resourceKey);
}
}
}