Skip to content

Commit bf1e40a

Browse files
authored
Code Quality: Merged App.ValueConverters with App.Converters (#12235)
1 parent ce2a09f commit bf1e40a

25 files changed

+56
-61
lines changed

src/Files.App/Converters/BoolToSelectionMode.cs renamed to src/Files.App/Converters/BoolToSelectionModeConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Files.App.Converters
88
{
9-
internal class BoolToSelectionMode : IValueConverter
9+
internal sealed class BoolToSelectionModeConverter : IValueConverter
1010
{
1111
public object Convert(object value, Type targetType, object parameter, string language)
1212
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Microsoft.UI.Xaml.Data;
55

6-
namespace Files.App.ValueConverters.EnumConverters
6+
namespace Files.App.Converters
77
{
88
internal sealed class ConflictResolveOptionToIndexConverter : IValueConverter
99
{

src/Files.App/Converters/Converters.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Files.App.Converters
1111
/// </summary>
1212
/// <typeparam name="TSource">The source type.</typeparam>
1313
/// <typeparam name="TTarget">The target type.</typeparam>
14-
public abstract class ValueConverter<TSource, TTarget> : IValueConverter
14+
internal abstract class ValueConverter<TSource, TTarget> : IValueConverter
1515
{
1616
/// <summary>
1717
/// Converts a source value to the target type.
@@ -89,7 +89,7 @@ public abstract class ValueConverter<TSource, TTarget> : IValueConverter
8989
/// <summary>
9090
/// The base class for converting instances of type T to object and vice versa.
9191
/// </summary>
92-
public abstract class ToObjectConverter<T> : ValueConverter<T?, object?>
92+
internal abstract class ToObjectConverter<T> : ValueConverter<T?, object?>
9393
{
9494
/// <summary>
9595
/// Converts a source value to the target type.
@@ -119,7 +119,7 @@ public abstract class ToObjectConverter<T> : ValueConverter<T?, object?>
119119
/// <summary>
120120
/// Converts a boolean to and from a visibility value.
121121
/// </summary>
122-
public class InverseBooleanConverter : ValueConverter<bool, bool>
122+
internal sealed class InverseBooleanConverter : ValueConverter<bool, bool>
123123
{
124124
/// <summary>
125125
/// Converts a source value to the target type.
@@ -146,7 +146,7 @@ protected override bool ConvertBack(bool value, object? parameter, string? langu
146146
}
147147
}
148148

149-
public class NullToTrueConverter : ValueConverter<object?, bool>
149+
internal sealed class NullToTrueConverter : ValueConverter<object?, bool>
150150
{
151151
/// <summary>
152152
/// Determines whether an inverse conversion should take place.
@@ -179,7 +179,7 @@ protected override bool Convert(object? value, object? parameter, string? langua
179179
}
180180
}
181181

182-
public class StringNullOrWhiteSpaceToTrueConverter : ValueConverter<string, bool>
182+
internal sealed class StringNullOrWhiteSpaceToTrueConverter : ValueConverter<string, bool>
183183
{
184184
/// <summary>
185185
/// Determines whether an inverse conversion should take place.

src/Files.App/Converters/DateTimeOffsetToString.cs renamed to src/Files.App/Converters/DateTimeOffsetToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Files.App.Converters
88
{
9-
internal class DateTimeOffsetToString : IValueConverter
9+
internal sealed class DateTimeOffsetToStringConverter : IValueConverter
1010
{
1111
private static readonly IDateTimeFormatter formatter = Ioc.Default.GetService<IDateTimeFormatter>();
1212

src/Files.App/Converters/DoubleArrayToString.cs renamed to src/Files.App/Converters/DoubleArrayToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Files.App.Converters
88
{
9-
internal class DoubleArrayToString : IValueConverter
9+
internal sealed class DoubleArrayToStringConverter : IValueConverter
1010
{
1111
public object Convert(object value, Type targetType, object parameter, string language)
1212
{

src/Files.App/Converters/DoubleToString.cs renamed to src/Files.App/Converters/DoubleToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Files.App.Converters
77
{
8-
internal class DoubleToString : IValueConverter
8+
internal sealed class DoubleToStringConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, string language)
1111
{

src/Files.App/ValueConverters/GenericEnumConverter.cs renamed to src/Files.App/Converters/GenericEnumConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Microsoft.UI.Xaml.Data;
55

6-
namespace Files.App.ValueConverters
6+
namespace Files.App.Converters
77
{
88
internal sealed class GenericEnumConverter : IValueConverter
99
{

src/Files.App/ValueConverters/ImageModelToImageConverter.cs renamed to src/Files.App/Converters/ImageModelToImageConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Microsoft.UI.Xaml.Data;
55

6-
namespace Files.App.ValueConverters
6+
namespace Files.App.Converters
77
{
88
internal sealed class ImageModelToImageConverter : IValueConverter
99
{

src/Files.App/Converters/MultiBooleanConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Files.App.Converters
77
{
8-
internal class MultiBooleanConverter
8+
internal sealed class MultiBooleanConverter
99
{
1010
public static Boolean OrConvert(bool a, bool b)
1111
=> (a || b);

src/Files.App/Converters/StorageDeleteOptionToBooleanConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Files.App.Converters
88
{
9-
internal class StorageDeleteOptionToBooleanConverter : IValueConverter
9+
internal sealed class StorageDeleteOptionToBooleanConverter : IValueConverter
1010
{
1111
public object Convert(object value, Type targetType, object parameter, string language)
1212
{

src/Files.App/Converters/StringArrayToString.cs renamed to src/Files.App/Converters/StringArrayToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Files.App.Converters
88
{
9-
internal class StringArrayToString : IValueConverter
9+
internal sealed class StringArrayToStringConverter : IValueConverter
1010
{
1111
public object Convert(object value, Type targetType, object parameter, string language)
1212
{

src/Files.App/ValueConverters/StringToBrushConverter.cs renamed to src/Files.App/Converters/StringToBrushConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Microsoft.UI.Xaml.Data;
66
using Microsoft.UI.Xaml.Media;
77

8-
namespace Files.App.ValueConverters
8+
namespace Files.App.Converters
99
{
1010
internal sealed class StringToBrushConverter : IValueConverter
1111
{
@@ -14,7 +14,7 @@ internal sealed class StringToBrushConverter : IValueConverter
1414
if (value is not string strValue)
1515
return null;
1616

17-
return new SolidColorBrush(ColorHelper.ToColor(strValue));
17+
return new SolidColorBrush(strValue.ToColor());
1818
}
1919

2020
public object ConvertBack(object value, Type targetType, object parameter, string language)

src/Files.App/Converters/UInt32ToString.cs renamed to src/Files.App/Converters/UInt32ToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Files.App.Converters
77
{
8-
internal class UInt32ToString : IValueConverter
8+
internal sealed class UInt32ToStringConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, string language)
1111
{

src/Files.App/Converters/VisibilityInvertConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Files.App.Converters
88
{
9-
public class VisibilityInvertConverter : IValueConverter
9+
internal sealed class VisibilityInvertConverter : IValueConverter
1010
{
1111
public object Convert(object value, Type targetType, object parameter, string language)
1212
{

src/Files.App/Dialogs/AddItemDialog.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
x:Class="Files.App.Dialogs.AddItemDialog"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:converters="using:Files.App.Converters"
67
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
78
xmlns:helpers="using:Files.App.Helpers"
89
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
xmlns:vc="using:Files.App.ValueConverters"
1010
xmlns:vm="using:Files.Backend.ViewModels.Dialogs.AddItemDialog"
1111
x:Name="AddDialog"
1212
Title="{helpers:ResourceString Name=AddDialog/Title}"
@@ -20,7 +20,7 @@
2020
mc:Ignorable="d">
2121

2222
<ContentDialog.Resources>
23-
<vc:ImageModelToImageConverter x:Key="ImageModelToImageConverter" />
23+
<converters:ImageModelToImageConverter x:Key="ImageModelToImageConverter" />
2424
</ContentDialog.Resources>
2525

2626
<Grid RowSpacing="25">

src/Files.App/Dialogs/FilesystemOperationDialog.xaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
x:Class="Files.App.Dialogs.FilesystemOperationDialog"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:converters="using:Files.App.Converters"
67
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
78
xmlns:helpers="using:Files.App.Helpers"
89
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
910
xmlns:ts="using:Files.App.TemplateSelectors"
1011
xmlns:tvc="using:CommunityToolkit.WinUI.UI.Converters"
11-
xmlns:vc="using:Files.App.ValueConverters"
12-
xmlns:vc2="using:Files.App.ValueConverters.EnumConverters"
13-
xmlns:vc3="using:Files.App.Converters"
1412
xmlns:vm="using:Files.Backend.ViewModels.Dialogs.FileSystemDialog"
1513
x:Name="RootDialog"
1614
Title="{x:Bind ViewModel.Title, Mode=OneWay}"
@@ -29,10 +27,10 @@
2927
<ContentDialog.Resources>
3028
<x:Double x:Key="ContentDialogMaxWidth">800</x:Double>
3129

32-
<vc:ImageModelToImageConverter x:Key="ImageModelToImageConverter" />
33-
<vc:GenericEnumConverter x:Key="GenericEnumConverter" />
34-
<vc2:ConflictResolveOptionToIndexConverter x:Key="ConflictResolveOptionToIndexConverter" />
35-
<vc3:VisibilityInvertConverter x:Key="VisibilityInvertConverter" />
30+
<converters:ImageModelToImageConverter x:Key="ImageModelToImageConverter" />
31+
<converters:GenericEnumConverter x:Key="GenericEnumConverter" />
32+
<converters:ConflictResolveOptionToIndexConverter x:Key="ConflictResolveOptionToIndexConverter" />
33+
<converters:VisibilityInvertConverter x:Key="VisibilityInvertConverter" />
3634
<tvc:BoolNegationConverter x:Key="BoolNegationConverter" />
3735

3836
<DataTemplate x:Key="ConflictItemDataTemplate" x:DataType="vm:FileSystemDialogConflictItemViewModel">

src/Files.App/ResourceDictionaries/PropertiesStyles.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464
<Setter Property="FontSize" Value="14" />
6565
</Style>
6666

67-
<converters:StringArrayToString x:Key="StringArrayToString" />
68-
<converters:UInt32ToString x:Key="UInt32ToString" />
69-
<converters:DoubleToString x:Key="DoubleToString" />
70-
<converters:DateTimeOffsetToString x:Key="DateTimeOffsetToString" />
67+
<converters:StringArrayToStringConverter x:Key="StringArrayToString" />
68+
<converters:UInt32ToStringConverter x:Key="UInt32ToString" />
69+
<converters:DoubleToStringConverter x:Key="DoubleToString" />
70+
<converters:DateTimeOffsetToStringConverter x:Key="DateTimeOffsetToString" />
7171

7272
<Style x:Key="Separator" TargetType="MenuFlyoutSeparator">
7373
<Setter Property="Grid.Column" Value="0" />

src/Files.App/UserControls/SidebarControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
xmlns:local="using:Files.App.UserControls"
99
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1010
xmlns:mconv="using:CommunityToolkit.WinUI.UI.Converters"
11+
xmlns:converters="using:Files.App.Converters"
1112
xmlns:dataitems="using:Files.App.Data.Items"
12-
xmlns:vc="using:Files.App.ValueConverters"
1313
HorizontalAlignment="Stretch"
1414
Collapsed="NavigationView_Collapsed"
1515
DisplayModeChanged="SidebarControl_DisplayModeChanged"
@@ -52,7 +52,7 @@
5252

5353
<mconv:BoolNegationConverter x:Key="BoolNegationConverter" />
5454
<mconv:StringFormatConverter x:Key="StringFormatConverter" />
55-
<vc:StringToBrushConverter x:Key="StringToBrushConverter" />
55+
<converters:StringToBrushConverter x:Key="StringToBrushConverter" />
5656
<DataTemplate x:Key="LocationNavItem" x:DataType="dataitems:LocationItem">
5757
<NavigationViewItem
5858
AllowDrop="True"

src/Files.App/UserControls/Widgets/FileTagsWidget.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
7+
xmlns:converters="using:Files.App.Converters"
78
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
89
xmlns:helpers="using:Files.App.Helpers"
910
xmlns:local="using:Files.App.UserControls.Widgets"
1011
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11-
xmlns:vc="using:Files.App.ValueConverters"
1212
xmlns:vm="using:Files.App.ViewModels.Widgets"
1313
d:DesignHeight="300"
1414
d:DesignWidth="400"
1515
mc:Ignorable="d">
1616

1717
<UserControl.Resources>
18-
<vc:StringToBrushConverter x:Key="StringToBrushConverter" />
19-
<vc:ImageModelToImageConverter x:Key="ImageModelToImageConverter" />
18+
<converters:StringToBrushConverter x:Key="StringToBrushConverter" />
19+
<converters:ImageModelToImageConverter x:Key="ImageModelToImageConverter" />
2020
</UserControl.Resources>
2121

2222
<!-- Collection of containers -->

src/Files.App/ViewModels/Properties/Items/FileProperty.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,29 @@ private IValueConverter GetConverter()
168168
{
169169
if (Value is uint)
170170
{
171-
return new UInt32ToString();
171+
return new UInt32ToStringConverter();
172172
}
173173

174174
if (Value is double)
175175
{
176-
return new DoubleToString();
176+
return new DoubleToStringConverter();
177177
}
178178

179179
if (Value is DateTimeOffset)
180180
{
181-
return new DateTimeOffsetToString();
181+
return new DateTimeOffsetToStringConverter();
182182
}
183183

184184
if (Value is not null && Value.GetType().IsArray)
185185
{
186186
if (Value.GetType().GetElementType().Equals(typeof(string)))
187187
{
188-
return new StringArrayToString();
188+
return new StringArrayToStringConverter();
189189
}
190190

191191
if (Value.GetType().GetElementType().Equals(typeof(double)))
192192
{
193-
return new DoubleArrayToString();
193+
return new DoubleArrayToStringConverter();
194194
}
195195
}
196196
return null;

src/Files.App/Views/LayoutModes/ColumnViewBase.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
xmlns:local="using:Files.App"
1212
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1313
xmlns:uc="using:Files.App.UserControls"
14-
xmlns:valueconverters="using:Files.App.ValueConverters"
1514
xmlns:wct="using:CommunityToolkit.WinUI.UI"
1615
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
1716
x:Name="PageRoot"
1817
mc:Ignorable="d">
1918

2019
<local:StandardViewBase.Resources>
2120

22-
<valueconverters:StringToBrushConverter x:Key="StringToBrushConverter" />
21+
<converters:StringToBrushConverter x:Key="StringToBrushConverter" />
2322
<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
2423
<wctconverters:BoolToVisibilityConverter
2524
x:Key="NegatedBoolToVisibilityConverter"
@@ -33,7 +32,7 @@
3332
x:Key="EmptyObjectToObjectConverter"
3433
EmptyValue="Collapsed"
3534
NotEmptyValue="Visible" />
36-
<converters:BoolToSelectionMode x:Key="BoolToSelectionModeConverter" />
35+
<converters:BoolToSelectionModeConverter x:Key="BoolToSelectionModeConverter" />
3736

3837
<Style TargetType="ListViewHeaderItem">
3938
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />

src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1616
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
1717
xmlns:uc="using:Files.App.UserControls"
18-
xmlns:valueconverters="using:Files.App.ValueConverters"
1918
xmlns:wct="using:CommunityToolkit.WinUI.UI"
2019
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
2120
x:Name="PageRoot"
@@ -46,8 +45,8 @@
4645
x:Key="EmptyObjectToObjectConverter"
4746
EmptyValue="Collapsed"
4847
NotEmptyValue="Visible" />
49-
<valueconverters:StringToBrushConverter x:Key="StringToBrushConverter" />
50-
<converters:BoolToSelectionMode x:Key="BoolToSelectionModeConverter" />
48+
<converters:StringToBrushConverter x:Key="StringToBrushConverter" />
49+
<converters:BoolToSelectionModeConverter x:Key="BoolToSelectionModeConverter" />
5150
<wctconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
5251

5352
<Style

src/Files.App/Views/LayoutModes/GridViewBrowser.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
1616
xmlns:tui="using:CommunityToolkit.WinUI.UI"
1717
xmlns:uc="using:Files.App.UserControls"
18-
xmlns:vc="using:Files.App.ValueConverters"
1918
xmlns:wctanimations="using:CommunityToolkit.WinUI.UI.Animations"
2019
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
2120
x:Name="PageRoot"
@@ -33,7 +32,7 @@
3332

3433
<root:StandardViewBase.Resources>
3534

36-
<vc:StringToBrushConverter x:Key="StringToBrushConverter" />
35+
<converters:StringToBrushConverter x:Key="StringToBrushConverter" />
3736
<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
3837
<wctconverters:BoolToVisibilityConverter
3938
x:Key="NegatedBoolToVisibilityConverter"
@@ -52,7 +51,7 @@
5251
x:Key="BoolToVisibilityConverter"
5352
FalseValue="Collapsed"
5453
TrueValue="Visible" />
55-
<converters:BoolToSelectionMode x:Key="BoolToSelectionModeConverter" />
54+
<converters:BoolToSelectionModeConverter x:Key="BoolToSelectionModeConverter" />
5655

5756
<DataTemplate x:Name="GridViewBrowserTemplate" x:DataType="filesystem:ListedItem">
5857
<UserControl>

0 commit comments

Comments
 (0)