Skip to content

Commit 648488b

Browse files
committed
feat(settings): Add AppVersionSettings for app-specific version tracking
- Create AppVersionSettings class to store application version independently from PleasantUI library version - Add Version, VersionType, and VersionLabel properties with DataMember serialization support - Include VersionTypeDescription computed property for display-friendly release channel names - Register AppVersionSettings in PleasantSettingsGenerationContext for JSON source generation - Add AppVersion property to PleasantSettings with null validation and initialization - Enables applications to manage their own versioning semantics separate from the UI framework
1 parent 968c236 commit 648488b

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

src/PleasantUI/Core/GenerationContexts/PleasantSettingsGenerationContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ namespace PleasantUI.Core.GenerationContexts;
44

55
[JsonSourceGenerationOptions(WriteIndented = true)]
66
[JsonSerializable(typeof(PleasantSettings))]
7+
[JsonSerializable(typeof(PleasantUI.Core.Settings.AppVersionSettings))]
78
internal partial class PleasantSettingsGenerationContext : JsonSerializerContext;

src/PleasantUI/Core/PleasantSettings.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class PleasantSettings : ViewModelBase
5757
private string _language = "en";
5858

5959
private WindowSettings _windowSettings;
60+
private AppVersionSettings _appVersion;
6061

6162
/// <summary>
6263
/// Gets the singleton instance of the PleasantSettings class.
@@ -199,12 +200,33 @@ public AvaloniaList<uint> ColorPalettes
199200
set => SetProperty(ref _colorPalettes, value);
200201
}
201202

203+
// ── App-specific version (separate from PleasantUI library version) ────────
204+
205+
/// <summary>
206+
/// Gets or sets application-specific version information.
207+
/// Use this to store and display your app's own version, release channel,
208+
/// and version label — independently of the PleasantUI library version.
209+
/// </summary>
210+
[DataMember]
211+
public AppVersionSettings AppVersion
212+
{
213+
get => _appVersion;
214+
set
215+
{
216+
if (value is null)
217+
throw new NullReferenceException("AppVersion is null");
218+
219+
SetProperty(ref _appVersion, value);
220+
}
221+
}
222+
202223
/// <summary>
203224
/// Initializes a new instance of the <see cref="PleasantSettings"/> class
204225
/// with default window and render settings.
205226
/// </summary>
206227
public PleasantSettings()
207228
{
208229
_windowSettings = new WindowSettings();
230+
_appVersion = new AppVersionSettings();
209231
}
210232
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace PleasantUI.Core.Settings;
4+
5+
/// <summary>
6+
/// Stores application-specific version information inside <see cref="PleasantSettings"/>.
7+
/// Reuses <see cref="PleasantVersionType"/> for release-channel semantics while keeping
8+
/// app versioning fully separate from the PleasantUI library version.
9+
/// </summary>
10+
public class AppVersionSettings : ViewModelBase
11+
{
12+
private string _version = string.Empty;
13+
private PleasantVersionType _versionType = PleasantVersionType.Stable;
14+
private string _versionLabel = "Version";
15+
16+
/// <summary>
17+
/// Gets or sets the application version string (e.g., "1.0.0", "2.3.1-beta").
18+
/// </summary>
19+
[DataMember]
20+
public string Version
21+
{
22+
get => _version;
23+
set => SetProperty(ref _version, value);
24+
}
25+
26+
/// <summary>
27+
/// Gets or sets the release channel / version type for the application.
28+
/// Reuses <see cref="PleasantVersionType"/> — Stable, BugFix, Alpha, Beta, RC, Canary.
29+
/// </summary>
30+
[DataMember]
31+
public PleasantVersionType VersionType
32+
{
33+
get => _versionType;
34+
set
35+
{
36+
if (SetProperty(ref _versionType, value))
37+
RaisePropertyChanged(nameof(VersionTypeDescription));
38+
}
39+
}
40+
41+
/// <summary>
42+
/// Gets or sets a custom label shown next to the version string (e.g., "Version", "App Version").
43+
/// Defaults to "Version".
44+
/// </summary>
45+
[DataMember]
46+
public string VersionLabel
47+
{
48+
get => _versionLabel;
49+
set => SetProperty(ref _versionLabel, value);
50+
}
51+
52+
/// <summary>
53+
/// Gets a display-friendly description of <see cref="VersionType"/>.
54+
/// Derived — not serialized.
55+
/// </summary>
56+
public string VersionTypeDescription => VersionType switch
57+
{
58+
PleasantVersionType.Stable => "Stable Release",
59+
PleasantVersionType.BugFix => "Bug Fix Release",
60+
PleasantVersionType.Alpha => "Alpha Pre-Release",
61+
PleasantVersionType.Beta => "Beta Pre-Release",
62+
PleasantVersionType.ReleaseCandidate => "Release Candidate",
63+
PleasantVersionType.Canary => "Canary Build",
64+
_ => "Unknown"
65+
};
66+
}

0 commit comments

Comments
 (0)