Skip to content

Commit 9f213a9

Browse files
authored
Code Quality: Code cleanup and formatting (#11156)
1 parent aefb485 commit 9f213a9

File tree

129 files changed

+1714
-774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1714
-774
lines changed

src/Files.App/BaseLayout.cs

Lines changed: 118 additions & 34 deletions
Large diffs are not rendered by default.

src/Files.App/Behaviors/StickyHeaderBehavior.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.
3-
// See the LICENSE file in the project root for more information.
4-
51
using CommunityToolkit.WinUI.UI;
62
using CommunityToolkit.WinUI.UI.Animations.Expressions;
73
using CommunityToolkit.WinUI.UI.Behaviors;
@@ -54,8 +50,12 @@ protected override bool Uninitialize()
5450
/// <summary>
5551
/// The UIElement that will be faded.
5652
/// </summary>
57-
public static readonly DependencyProperty HeaderElementProperty = DependencyProperty.Register(
58-
nameof(HeaderElement), typeof(UIElement), typeof(StickyHeaderBehavior), new PropertyMetadata(null, PropertyChangedCallback));
53+
public static readonly DependencyProperty HeaderElementProperty =
54+
DependencyProperty.Register(
55+
nameof(HeaderElement),
56+
typeof(UIElement),
57+
typeof(StickyHeaderBehavior),
58+
new PropertyMetadata(null, PropertyChangedCallback));
5959

6060
private ScrollViewer _scrollViewer;
6161
private CompositionPropertySet _scrollProperties;
@@ -71,8 +71,8 @@ protected override bool Uninitialize()
7171
/// </remarks>
7272
public UIElement HeaderElement
7373
{
74-
get { return (UIElement)GetValue(HeaderElementProperty); }
75-
set { SetValue(HeaderElementProperty, value); }
74+
get => (UIElement)GetValue(HeaderElementProperty);
75+
set => SetValue(HeaderElementProperty, value);
7676
}
7777

7878
/// <summary>
@@ -119,7 +119,7 @@ private bool AssignAnimation()
119119
if (HeaderElement is null && listView is not null)
120120
HeaderElement = listView.Header as UIElement;
121121

122-
var headerElement = HeaderElement as FrameworkElement;
122+
FrameworkElement? headerElement = HeaderElement as FrameworkElement;
123123

124124
if (headerElement is null || headerElement.RenderSize.Height == 0)
125125
return false;
@@ -212,6 +212,7 @@ private void ScrollViewer_GotFocus(object sender, RoutedEventArgs e)
212212
var scroller = (ScrollViewer)sender;
213213

214214
object focusedElement;
215+
215216
if (IsXamlRootAvailable && scroller.XamlRoot is not null)
216217
{
217218
focusedElement = FocusManager.GetFocusedElement(scroller.XamlRoot);
@@ -239,4 +240,4 @@ private void ScrollViewer_GotFocus(object sender, RoutedEventArgs e)
239240
}
240241
}
241242
}
242-
}
243+
}

src/Files.App/CommandLine/CommandLineParser.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private static ParsedCommands ParseSplitArguments(List<KeyValuePair<string, stri
7070
Debug.WriteLine($"Exception in CommandLineParser.cs\\ParseUntrustedCommands with message: {ex.Message}");
7171
command.Type = ParsedCommandType.Unknown;
7272
}
73+
7374
break;
7475
}
7576

@@ -149,16 +150,21 @@ private static KeyValuePair<string, string[]> ParseData(string[] args, int index
149150
{
150151
string? key = null;
151152
var val = new List<string>();
153+
152154
if (args[index].StartsWith('-') || args[index].StartsWith('/'))
153155
{
154156
if (args[index].Contains(':', StringComparison.Ordinal))
155157
{
156158
string argument = args[index];
157159
int endIndex = argument.IndexOf(':');
158-
key = argument.Substring(1, endIndex - 1); // trim the '/' and the ':'.
160+
161+
// Trim the '/' and the ':'
162+
key = argument.Substring(1, endIndex - 1);
163+
159164
int valueStart = endIndex + 1;
160-
val.Add(valueStart < argument.Length ? argument.Substring(
161-
valueStart, argument.Length - valueStart) : null);
165+
val.Add(valueStart < argument.Length
166+
? argument.Substring(valueStart, argument.Length - valueStart)
167+
: null);
162168
}
163169
else
164170
{
@@ -175,4 +181,4 @@ private static KeyValuePair<string, string[]> ParseData(string[] args, int index
175181
return key is not null ? new KeyValuePair<string, string[]>(key, val.ToArray()) : default;
176182
}
177183
}
178-
}
184+
}

src/Files.App/CommandLine/ParsedCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ internal class ParsedCommand
77
{
88
public ParsedCommandType Type { get; set; }
99

10-
public string Payload => Args.FirstOrDefault();
10+
public string Payload
11+
=> Args.FirstOrDefault();
1112

1213
public List<string> Args { get; set; }
1314

1415
public ParsedCommand() =>
1516
Args = new List<string>();
1617
}
17-
}
18+
}

src/Files.App/CommandLine/ParsedCommandType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ internal enum ParsedCommandType
1010
SelectItem,
1111
TagFiles
1212
}
13-
}
13+
}

src/Files.App/CommandLine/ParsedCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace Files.App.CommandLine
55
internal class ParsedCommands : List<ParsedCommand>
66
{
77
}
8-
}
8+
}

src/Files.App/Constants.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,20 @@ public static class UI
9292

9393
public const double MaximumSidebarWidth = 500;
9494

95-
public const double ContextMenuMaxHeight = 480; // For contextmenu hacks, must match WinUI style
96-
public const double ContextMenuSecondaryItemsHeight = 32; // For contextmenu hacks, must match WinUI style
97-
public const double ContextMenuPrimaryItemsHeight = 48; // For contextmenu hacks, must match WinUI style
98-
public const double ContextMenuLabelMargin = 10; // For contextmenu hacks
99-
public const double ContextMenuItemsMaxWidth = 250; // For contextmenu hacks
95+
// For contextmenu hacks, must match WinUI style
96+
public const double ContextMenuMaxHeight = 480;
97+
98+
// For contextmenu hacks, must match WinUI style
99+
public const double ContextMenuSecondaryItemsHeight = 32;
100+
101+
// For contextmenu hacks, must match WinUI style
102+
public const double ContextMenuPrimaryItemsHeight = 48;
103+
104+
// For contextmenu hacks
105+
public const double ContextMenuLabelMargin = 10;
106+
107+
// For contextmenu hacks
108+
public const double ContextMenuItemsMaxWidth = 250;
100109
}
101110

102111
public static class Browser
@@ -105,7 +114,8 @@ public static class GridViewBrowser
105114
{
106115
public const int GridViewIncrement = 20;
107116

108-
public const int GridViewSizeMax = 300; // Max achievable ctrl + scroll, not a default layout size.
117+
// Max achievable ctrl + scroll, not a default layout size
118+
public const int GridViewSizeMax = 300;
109119

110120
public const int GridViewSizeLarge = 220;
111121

@@ -208,4 +218,4 @@ public static class GitHub
208218
public const string SupportUsUrl = @"https://github.com/sponsors/yaira2";
209219
}
210220
}
211-
}
221+
}

src/Files.App/Controllers/IJson.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ internal interface IJson
66

77
void SaveModel();
88
}
9-
}
9+
}

src/Files.App/Converters/BoolToSelectionMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
1616
return ((value as ListViewSelectionMode?) ?? ListViewSelectionMode.Extended) == ListViewSelectionMode.Multiple;
1717
}
1818
}
19-
}
19+
}

src/Files.App/Converters/Converters.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ namespace Files.App.Converters
99
/// </summary>
1010
/// <typeparam name="TSource">The source type.</typeparam>
1111
/// <typeparam name="TTarget">The target type.</typeparam>
12-
public abstract class ValueConverter<TSource, TTarget>
13-
: IValueConverter
12+
public abstract class ValueConverter<TSource, TTarget> : IValueConverter
1413
{
1514
/// <summary>
1615
/// Converts a source value to the target type.
@@ -88,8 +87,7 @@ public abstract class ValueConverter<TSource, TTarget>
8887
/// <summary>
8988
/// The base class for converting instances of type T to object and vice versa.
9089
/// </summary>
91-
public abstract class ToObjectConverter<T>
92-
: ValueConverter<T?, object?>
90+
public abstract class ToObjectConverter<T> : ValueConverter<T?, object?>
9391
{
9492
/// <summary>
9593
/// Converts a source value to the target type.
@@ -119,8 +117,7 @@ public abstract class ToObjectConverter<T>
119117
/// <summary>
120118
/// Converts a boolean to and from a visibility value.
121119
/// </summary>
122-
public class InverseBooleanConverter
123-
: ValueConverter<bool, bool>
120+
public class InverseBooleanConverter : ValueConverter<bool, bool>
124121
{
125122
/// <summary>
126123
/// Converts a source value to the target type.
@@ -147,8 +144,7 @@ protected override bool ConvertBack(bool value, object? parameter, string? langu
147144
}
148145
}
149146

150-
public class NullToTrueConverter
151-
: ValueConverter<object?, bool>
147+
public class NullToTrueConverter : ValueConverter<object?, bool>
152148
{
153149
/// <summary>
154150
/// Determines whether an inverse conversion should take place.
@@ -181,8 +177,7 @@ protected override bool Convert(object? value, object? parameter, string? langua
181177
}
182178
}
183179

184-
public class StringNullOrWhiteSpaceToTrueConverter
185-
: ValueConverter<string, bool>
180+
public class StringNullOrWhiteSpaceToTrueConverter : ValueConverter<string, bool>
186181
{
187182
/// <summary>
188183
/// Determines whether an inverse conversion should take place.
@@ -214,4 +209,4 @@ protected override string ConvertBack(bool value, object? parameter, string? lan
214209
return string.Empty;
215210
}
216211
}
217-
}
212+
}

src/Files.App/Converters/DateTimeOffsetToString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2828
}
2929
}
3030
}
31-
}
31+
}

src/Files.App/Converters/DoubleArrayToString.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2727
{
2828
var strArray = (value as string).Split("; ");
2929
var array = new double[strArray.Length];
30+
3031
for (int i = 0; i < strArray.Length; i++)
3132
{
3233
try
@@ -40,4 +41,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
4041
return array;
4142
}
4243
}
43-
}
44+
}

src/Files.App/Converters/DoubleToString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2727
}
2828
}
2929
}
30-
}
30+
}

src/Files.App/Converters/IntToGroupOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2323
}
2424
}
2525
}
26-
}
26+
}

src/Files.App/Converters/IntToSortDirection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2323
}
2424
}
2525
}
26-
}
26+
}

src/Files.App/Converters/IntToSortOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2323
}
2424
}
2525
}
26-
}
26+
}

src/Files.App/Converters/MiddleTextEllipsisConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
3636
throw new NotImplementedException();
3737
}
3838
}
39-
}
39+
}

src/Files.App/Converters/MultiBooleanConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public static Visibility OrConvertToVisibility(bool a, bool b)
2323
public static Visibility OrNotConvertToVisibility(bool a, bool b)
2424
=> OrConvertToVisibility(a, !b);
2525
}
26-
}
26+
}

src/Files.App/Converters/StorageDeleteOptionToBooleanConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
1616
return (value is bool bl && bl) ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default;
1717
}
1818
}
19-
}
19+
}

src/Files.App/Converters/StringArrayToString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2727
return (value as string).Split("; ");
2828
}
2929
}
30-
}
30+
}

src/Files.App/Converters/UInt32ToString.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
1414
{
1515
try
1616
{
17-
return UInt32.Parse(value as string);
17+
return uint.Parse(value as string);
1818
}
1919
catch (FormatException)
2020
{
2121
return null;
2222
}
2323
}
2424
}
25-
}
25+
}

src/Files.App/Converters/VisibilityInvertConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public object Convert(object value, Type targetType, object parameter, string la
1212
{
1313
return isVisible ? Visibility.Collapsed : Visibility.Visible;
1414
}
15+
1516
return (Visibility)value == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
1617
}
1718

@@ -20,4 +21,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2021
throw new NotImplementedException();
2122
}
2223
}
23-
}
24+
}

src/Files.App/DataModels/AppModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public AppModel()
2828
FoldersSettings.PropertyChanged += FoldersSettings_PropertyChanged; ;
2929
Clipboard.ContentChanged += Clipboard_ContentChanged;
3030

31-
//todo: this doesn't belong here
31+
// TODO: This doesn't belong here
3232
DetectFontName();
3333
}
3434

@@ -40,7 +40,7 @@ private void FoldersSettings_PropertyChanged(object? sender, System.ComponentMod
4040
}
4141
}
4242

43-
//todo: refactor this method
43+
// TODO: Refactor this method
4444
public void Clipboard_ContentChanged(object sender, object e)
4545
{
4646
try
@@ -105,7 +105,7 @@ public FontFamily SymbolFontFamily
105105
set => SetProperty(ref symbolFontFamily, value);
106106
}
107107

108-
//todo: refactor this method
108+
// TODO: Refactor this method
109109
private void DetectFontName()
110110
{
111111
var rawVersion = ulong.Parse(AnalyticsInfo.VersionInfo.DeviceFamilyVersion);
@@ -116,4 +116,4 @@ private void DetectFontName()
116116
SymbolFontFamily = (isWindows11) ? new FontFamily("Segoe Fluent Icons") : new FontFamily("Segoe MDL2 Assets");
117117
}
118118
}
119-
}
119+
}

0 commit comments

Comments
 (0)