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

Code Quality: Formatted code for readability #10537

Merged
merged 10 commits into from
Jan 16, 2023
12 changes: 3 additions & 9 deletions src/Files.App/Helpers/ResourceHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
17 changes: 6 additions & 11 deletions src/Files.App/Serialization/BaseObservableJsonSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@ internal abstract class BaseObservableJsonSettings : BaseJsonSettings, INotifyPr
{
public event PropertyChangedEventHandler? PropertyChanged;

protected override bool Set<TValue>(TValue? value, [CallerMemberName] string propertyName = "")
where TValue : default
protected override bool Set<TValue>(TValue? value, [CallerMemberName] string propertyName = "") where TValue : default
{
if (base.Set<TValue>(value, propertyName))
{
OnPropertyChanged(propertyName);
return true;
}
if (!base.Set<TValue>(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));
}
}
18 changes: 5 additions & 13 deletions src/Files.App/Shell/ContextMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ namespace Files.App.Shell
{
public class ContextMenuItem : Win32ContextMenuItem, IDisposable
{
public ContextMenuItem()
{
SubItems = new List<Win32ContextMenuItem>();
}
public ContextMenuItem() => SubItems = new List<Win32ContextMenuItem>();

public void Dispose()
{
Expand All @@ -19,17 +16,12 @@ public void Dispose()

protected virtual void Dispose(bool disposing)
{
if (disposing)
if (disposing && SubItems is not null)
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
{
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;
}
}
}
Expand Down