fix(ui): show short semver (major.minor.patch) in version footer\n\n- Parse AssemblyInformationalVersion and display only first 3 segments\n- Bind Text to AppVersionShort to hide '+sha' build metadata
This commit is contained in:
parent
74c5b403ae
commit
1eb7f13a05
2 changed files with 12 additions and 3 deletions
|
@ -7,6 +7,7 @@ using AdvancedCalculator.Services;
|
|||
using CSMic;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AdvancedCalculator.ViewModels;
|
||||
|
||||
|
@ -43,12 +44,20 @@ public partial class MainViewModel : ViewModelBase
|
|||
public ObservableCollection<HistoryItem> History { get; }
|
||||
public ObservableCollection<VariableItem> Variables { get; }
|
||||
|
||||
// App version string, sourced from AssemblyInformationalVersion
|
||||
public string AppVersion { get; } =
|
||||
// App version strings
|
||||
private static readonly string s_appVersion =
|
||||
typeof(MainViewModel).Assembly
|
||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
||||
.InformationalVersion ?? "0.0.0";
|
||||
|
||||
private static readonly string s_appVersionShort =
|
||||
Regex.Match(s_appVersion, @"^(\d+)\.(\d+)\.(\d+)").Success
|
||||
? Regex.Match(s_appVersion, @"^(\d+)\.(\d+)\.(\d+)").Value
|
||||
: s_appVersion;
|
||||
|
||||
public string AppVersion => s_appVersion;
|
||||
public string AppVersionShort => s_appVersionShort;
|
||||
|
||||
[RelayCommand]
|
||||
private void ToggleFunctions()
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
<!-- Bottom sticky version bar -->
|
||||
<Border Grid.Row="1" Padding="10" Background="{DynamicResource Brush.Surface}"
|
||||
BorderBrush="{DynamicResource Brush.Border}" BorderThickness="0,1,0,0">
|
||||
<TextBlock Text="{Binding AppVersion, StringFormat='Version {0}'}"
|
||||
<TextBlock Text="{Binding AppVersionShort, StringFormat='Version {0}'}"
|
||||
HorizontalAlignment="Left"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue