diff --git a/src/Files.App/Helpers/ResourceHelpers.cs b/src/Files.App/Helpers/ResourceHelpers.cs index 1f15fd71f616..3bb5db168427 100644 --- a/src/Files.App/Helpers/ResourceHelpers.cs +++ b/src/Files.App/Helpers/ResourceHelpers.cs @@ -6,16 +6,10 @@ namespace Files.App.Helpers [MarkupExtensionReturnType(ReturnType = typeof(string))] public sealed class ResourceString : MarkupExtension { - private static ResourceLoader resourceLoader = new ResourceLoader(); + private static readonly ResourceLoader resourceLoader = new(); - public string Name - { - get; set; - } + public string Name { get; set; } = string.Empty; - protected override object ProvideValue() - { - return resourceLoader.GetString(this.Name); - } + protected override object ProvideValue() => resourceLoader.GetString(Name); } } diff --git a/src/Files.App/Serialization/BaseObservableJsonSettings.cs b/src/Files.App/Serialization/BaseObservableJsonSettings.cs index b30f9f134fe1..f9d60ba6fee3 100644 --- a/src/Files.App/Serialization/BaseObservableJsonSettings.cs +++ b/src/Files.App/Serialization/BaseObservableJsonSettings.cs @@ -7,21 +7,16 @@ internal abstract class BaseObservableJsonSettings : BaseJsonSettings, INotifyPr { public event PropertyChangedEventHandler? PropertyChanged; - protected override bool Set(TValue? value, [CallerMemberName] string propertyName = "") - where TValue : default + protected override bool Set(TValue? value, [CallerMemberName] string propertyName = "") where TValue : default { - if (base.Set(value, propertyName)) - { - OnPropertyChanged(propertyName); - return true; - } + if (!base.Set(value, propertyName)) + return false; - return false; + OnPropertyChanged(propertyName); + return true; } protected void OnPropertyChanged([CallerMemberName] string propertyName = "") - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } \ No newline at end of file diff --git a/src/Files.App/Shell/ContextMenuItem.cs b/src/Files.App/Shell/ContextMenuItem.cs index 0309c5b3347a..9b92f5011410 100644 --- a/src/Files.App/Shell/ContextMenuItem.cs +++ b/src/Files.App/Shell/ContextMenuItem.cs @@ -6,10 +6,7 @@ namespace Files.App.Shell { public class ContextMenuItem : Win32ContextMenuItem, IDisposable { - public ContextMenuItem() - { - SubItems = new List(); - } + public ContextMenuItem() => SubItems = new List(); public void Dispose() { @@ -19,17 +16,12 @@ public void Dispose() protected virtual void Dispose(bool disposing) { - if (disposing) + if (disposing && SubItems is not null) { - if (SubItems is not null) - { - foreach (var si in SubItems) - { - (si as IDisposable)?.Dispose(); - } + foreach (var subItem in SubItems) + (subItem as IDisposable)?.Dispose(); - SubItems = null; - } + SubItems = null; } } }