Skip to content

Commit 579328f

Browse files
committed
Replace PropertyChanged.Fody with source generator
1 parent 7a43035 commit 579328f

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

src/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ guidelines = 80
1010
[*.cs]
1111
file_header_template = This Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.
1212
guidelines = 80, 120
13+
propertychanged.first_letter_capitalization = lower_case
1314

1415
# Xml files
1516
[*.xml]

src/JsonConfig.cs

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,52 @@
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
using Newtonsoft.Json;
6-
using PropertyChanged;
6+
using PropertyChanged.SourceGenerator;
77
using System;
88
using System.ComponentModel;
99
using System.IO;
1010
using System.Windows.Forms;
1111

1212
namespace WinDynamicDesktop
1313
{
14-
[AddINotifyPropertyChangedInterface]
15-
public class AppConfig : INotifyPropertyChanged
14+
public partial class AppConfig : INotifyPropertyChanged
1615
{
17-
#pragma warning disable 67
18-
public event PropertyChangedEventHandler PropertyChanged;
19-
#pragma warning restore 67
20-
2116
// Schedule settings
22-
public int locationMode { get; set; }
23-
public string location { get; set; }
24-
public double? latitude { get; set; }
25-
public double? longitude { get; set; }
26-
public string sunriseTime { get; set; }
27-
public string sunsetTime { get; set; }
28-
public int sunriseSunsetDuration { get; set; }
17+
[Notify] private int _locationMode { get; set; }
18+
[Notify] private string _location { get; set; }
19+
[Notify] private double? _latitude { get; set; }
20+
[Notify] private double? _longitude { get; set; }
21+
[Notify] private string _sunriseTime { get; set; }
22+
[Notify] private string _sunsetTime { get; set; }
23+
[Notify] private int _sunriseSunsetDuration { get; set; }
2924

3025
// Theme settings
31-
public string[] activeThemes { get; set; }
32-
[Obsolete("Will be removed in v6")]
26+
[Notify] private string[] _activeThemes { get; set; }
27+
[Obsolete("Deprecated")]
3328
public bool darkMode { get; set; }
34-
public int appearanceMode { get; set; }
35-
[Obsolete("Will be removed in v6")]
29+
[Notify] private int _appearanceMode { get; set; }
30+
[Obsolete("Deprecated")]
3631
public bool changeLockScreen { get; set; }
37-
public int lockScreenDisplayIndex { get; set; } = -1;
38-
public string lockScreenTheme { get; set; }
39-
[Obsolete("Will be removed in v6")]
32+
[Notify] private int _lockScreenDisplayIndex { get; set; } = -1;
33+
[Notify] private string _lockScreenTheme { get; set; }
34+
[Obsolete("Deprecated")]
4035
public bool enableShuffle { get; set; }
41-
public int themeShuffleMode { get; set; } = (int)ShufflePeriod.EveryDay;
42-
[Obsolete("Will be removed in v6")]
36+
[Notify] private int _themeShuffleMode { get; set; } = (int)ShufflePeriod.EveryDay;
37+
[Obsolete("Deprecated")]
4338
public string lastShuffleDate { get; set; }
44-
public string lastShuffleTime { get; set; }
45-
public string[] shuffleHistory { get; set; }
46-
public string[] favoriteThemes { get; set; }
47-
public bool showInstalledOnly { get; set; }
39+
[Notify] private string _lastShuffleTime { get; set; }
40+
[Notify] private string[] _shuffleHistory { get; set; }
41+
[Notify] private string[] _favoriteThemes { get; set; }
42+
[Notify] private bool _showInstalledOnly { get; set; }
4843

4944
// General settings
50-
public string language { get; set; }
51-
public bool autoUpdateCheck { get; set; } = true;
52-
public string lastUpdateCheckTime { get; set; }
53-
public bool hideTrayIcon { get; set; }
54-
public bool fullScreenPause { get; set; }
55-
public bool enableScripts { get; set; }
56-
public bool debugLogging { get; set; }
45+
[Notify] private string _language { get; set; }
46+
[Notify] private bool _autoUpdateCheck { get; set; } = true;
47+
[Notify] private string _lastUpdateCheckTime { get; set; }
48+
[Notify] private bool _hideTrayIcon { get; set; }
49+
[Notify] private bool _fullScreenPause { get; set; }
50+
[Notify] private bool _enableScripts { get; set; }
51+
[Notify] private bool _debugLogging { get; set; }
5752
}
5853

5954
class JsonConfig

src/WinDynamicDesktop.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
<PackageReference Include="GeoTimeZone" Version="5.3.0" />
3131
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
3232
<PackageReference Include="NGettext" Version="0.6.7" />
33-
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="All" />
33+
<PackageReference Include="PropertyChanged.SourceGenerator" Version="1.0.8">
34+
<PrivateAssets>all</PrivateAssets>
35+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
36+
</PackageReference>
3437
<PackageReference Include="RestSharp" Version="112.1.0" />
3538
<PackageReference Include="SunCalcNet" Version="1.2.2" />
3639
<PackageReference Include="TimeZoneConverter" Version="6.1.0" />

0 commit comments

Comments
 (0)