Skip to content

Commit 3f08fd9

Browse files
Merge pull request #18 from atc-net/feature/maintenance
Fix ResolveTemplateValue for default-settings and add UnitType for some settings
2 parents 87017cb + 1e9a063 commit 3f08fd9

24 files changed

+225
-83
lines changed
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsettings/@EntryIndexedValue">True</s:Boolean>
33
<s:Boolean x:Key="/Default/UserDictionary/Words/=postgre/@EntryIndexedValue">True</s:Boolean>
4-
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
4+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean>
5+
<s:Boolean x:Key="/Default/UserDictionary/Words/=SYSLIB/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
<ItemGroup Label="Code Analyzers">
4242
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
4343
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
44-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110" PrivateAssets="All" />
44+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.136" PrivateAssets="All" />
4545
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
4646
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
47-
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982" PrivateAssets="All" />
47+
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.16.0.82469" PrivateAssets="All" />
4848
</ItemGroup>
4949

5050
</Project>

src/Atc.Installer.Integration.Azure/Atc.Installer.Integration.Azure.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Atc" Version="2.0.386" />
9+
<PackageReference Include="Atc" Version="2.0.398" />
1010
<PackageReference Include="Azure.Identity" Version="1.10.4" />
1111
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
1212
</ItemGroup>

src/Atc.Installer.Integration.PostgreSql/Atc.Installer.Integration.PostgreSql.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Npgsql" Version="8.0.0" />
9+
<PackageReference Include="Npgsql" Version="8.0.1" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

src/Atc.Installer.Integration.WindowsApplication/Atc.Installer.Integration.WindowsApplication.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Atc" Version="2.0.386" />
9+
<PackageReference Include="Atc" Version="2.0.398" />
1010
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
1111
</ItemGroup>
1212

src/Atc.Installer.Integration/Atc.Installer.Integration.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Atc" Version="2.0.386" />
21+
<PackageReference Include="Atc" Version="2.0.398" />
2222
</ItemGroup>
2323

2424
</Project>

src/Atc.Installer.Wpf.App/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[assembly: AssemblyCompany("atc-net")]
66
[assembly: AssemblyProduct("Atc.Installer")]
77
[assembly: AssemblyTitle("Atc.Installer")]
8-
[assembly: AssemblyVersion("1.0.17.0")]
9-
[assembly: AssemblyInformationalVersion("1.0.17.0")]
10-
[assembly: AssemblyFileVersion("1.0.17.0")]
8+
[assembly: AssemblyVersion("1.0.18.0")]
9+
[assembly: AssemblyInformationalVersion("1.0.18.0")]
10+
[assembly: AssemblyFileVersion("1.0.18.0")]
1111
[assembly: System.Resources.NeutralResourcesLanguage("en")]
1212
[assembly: System.Runtime.Versioning.TargetPlatform("Windows7.0")]
1313
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows7.0")]

src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
</ItemGroup>
4444

4545
<ItemGroup>
46-
<PackageReference Include="Atc.Wpf" Version="2.0.312" />
47-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.312" />
48-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.312" />
49-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.312" />
46+
<PackageReference Include="Atc.Wpf" Version="2.0.379" />
47+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.379" />
48+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.379" />
49+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.379" />
5050
<PackageReference Include="ClosedXML" Version="0.104.0-preview2" />
5151
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
5252
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />

src/Atc.Installer.Wpf.App/MainWindowViewModel.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ private async Task CheckForUpdates()
322322
}
323323
}
324324

325+
[SuppressMessage("Blocker Bug", "S2930:\"IDisposables\" should be disposed", Justification = "OK.")]
325326
private void StartMonitoringServices()
326327
{
327328
cancellationTokenSource = new CancellationTokenSource();
@@ -336,11 +337,13 @@ await Task
336337

337338
foreach (var vm in ComponentProviders)
338339
{
339-
if (!vm.IsBusy)
340+
if (vm.IsBusy)
340341
{
341-
vm.CheckPrerequisitesState();
342-
vm.CheckServiceState();
342+
continue;
343343
}
344+
345+
vm.CheckPrerequisitesState();
346+
vm.CheckServiceState();
344347
}
345348
}
346349
},
@@ -442,6 +445,7 @@ private void AddComponentProviderPostgreSql(
442445
ComponentProviders.Add(vm);
443446
}
444447

448+
[SuppressMessage("Major Bug", "S2583:Conditionally executed code should be reachable", Justification = "OK.")]
445449
private void Populate(
446450
FileInfo installationFile,
447451
InstallationOption installationOptions)

src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/Atc.Installer.Wpf.ComponentProvider.ElasticSearch.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.312" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.312" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.312" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.312" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.379" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.379" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.379" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.379" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.312" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.312" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.312" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.312" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.379" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.379" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.379" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.379" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/Atc.Installer.Wpf.ComponentProvider.PostgreSql.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.312" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.312" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.312" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.312" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.379" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.379" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.379" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.379" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/Atc.Installer.Wpf.ComponentProvider.WindowsApplication.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.312" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.312" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.312" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.312" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.379" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.379" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.379" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.379" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider/Atc.Installer.Wpf.ComponentProvider.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
</ItemGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Atc" Version="2.0.386" />
19-
<PackageReference Include="Atc.Wpf" Version="2.0.312" />
20-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.312" />
21-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.312" />
22-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.312" />
18+
<PackageReference Include="Atc" Version="2.0.398" />
19+
<PackageReference Include="Atc.Wpf" Version="2.0.379" />
20+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.379" />
21+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.379" />
22+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.379" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider/Controls/ApplicationSettingsViewModel.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ item.TemplateLocations is not null &&
471471
keyValueTemplateItem.TemplateLocations is not null &&
472472
keyValueTemplateItem.Template.Contains(updateItem.Key, StringComparison.Ordinal))
473473
{
474-
keyValueTemplateItem.Value = ResolveTemplateValue(updateItem, componentProvider, keyValueTemplateItem.Template);
474+
var (resolvedValue, _) = componentProvider.ResolveValueAndTemplateLocations(keyValueTemplateItem.Template);
475+
keyValueTemplateItem.Value = resolvedValue;
475476
}
476477
}
477478
}
@@ -486,7 +487,8 @@ keyValueTemplateItem.TemplateLocations is not null &&
486487
keyValueTemplateItem.TemplateLocations is not null &&
487488
keyValueTemplateItem.Template.Contains(updateItem.Key, StringComparison.Ordinal))
488489
{
489-
keyValueTemplateItem.Value = ResolveTemplateValue(updateItem, componentProvider, keyValueTemplateItem.Template);
490+
var (resolvedValue, _) = componentProvider.ResolveValueAndTemplateLocations(keyValueTemplateItem.Template);
491+
keyValueTemplateItem.Value = resolvedValue;
490492
}
491493
}
492494
}

src/Atc.Installer.Wpf.ComponentProvider/Controls/ConfigurationSettingsFilesView.xaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
xmlns:controls="clr-namespace:Atc.Installer.Wpf.ComponentProvider.Controls"
77
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:valueConverters="clr-namespace:Atc.Installer.Wpf.ComponentProvider.ValueConverters"
910
xmlns:viewModels="clr-namespace:Atc.Installer.Wpf.ComponentProvider.ViewModels"
1011
d:DataContext="{d:DesignInstance Type=controls:ConfigurationSettingsFilesViewModel}"
1112
d:DesignHeight="450"
1213
d:DesignWidth="800"
1314
mc:Ignorable="d">
1415

16+
<UserControl.Resources>
17+
<valueConverters:ConfigurationKeyToUnitTypeValueConverter x:Key="ConfigurationKeyToUnitTypeValueConverter" />
18+
</UserControl.Resources>
19+
1520
<StackPanel Orientation="Vertical">
1621
<ItemsControl ItemsSource="{Binding Path=JsonItems}">
1722
<ItemsControl.ItemTemplate>
@@ -90,9 +95,13 @@
9095
DisplayMemberBinding="{Binding Path=Key}"
9196
Header="Key" />
9297
<GridViewColumn
93-
Width="500"
98+
Width="150"
9499
DisplayMemberBinding="{Binding Path=Value}"
95100
Header="Value" />
101+
<GridViewColumn
102+
Width="80"
103+
DisplayMemberBinding="{Binding Path=Key, Converter={StaticResource ConfigurationKeyToUnitTypeValueConverter}}"
104+
Header="UnitType" />
96105
<GridViewColumn
97106
Width="Auto"
98107
DisplayMemberBinding="{Binding Path=Template}"

src/Atc.Installer.Wpf.ComponentProvider/Factories/LabelControlsFactory.cs

+30-2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public static IList<ILabelControlBase> CreateForApplicationSettings(
107107
return labelControls;
108108
}
109109

110+
[SuppressMessage("Security", "MA0009:Add regex evaluation timeout", Justification = "OK - For now.")]
111+
[SuppressMessage("Performance", "MA0110:Use the Regex source generator", Justification = "OK - For now.")]
112+
[SuppressMessage("Performance", "SYSLIB1045:Convert to 'GeneratedRegexAttribute'.", Justification = "OK - For now.")]
110113
public static IList<ILabelControlBase> CreateForConfigurationSettingsFiles(
111114
ComponentProviderViewModel? refComponentProvider,
112115
KeyValueTemplateItemViewModel? updateItem)
@@ -120,25 +123,50 @@ public static IList<ILabelControlBase> CreateForConfigurationSettingsFiles(
120123
MinLength = 1,
121124
};
122125

126+
var valueLabelRegexPattern = string.Empty;
127+
var sbValueLabelText = new StringBuilder();
128+
sbValueLabelText.Append("Value");
129+
123130
if (updateItem is not null)
124131
{
125132
labelTextBoxKey.IsMandatory = false;
126133
labelTextBoxKey.IsEnabled = false;
127134
labelTextBoxKey.Text = updateItem.Key;
135+
136+
if (ConfigurationKeyToUnitTypeValueConverter.TryParse(updateItem.Key, out var unitType))
137+
{
138+
sbValueLabelText.Append(" in ");
139+
sbValueLabelText.Append(unitType.ToLower(GlobalizationConstants.EnglishCultureInfo));
140+
valueLabelRegexPattern = ConfigurationKeyToUnitTypeValueConverter.GetRegexPatternFromUnitType(unitType);
141+
}
128142
}
129143

130144
labelControls.Add(labelTextBoxKey);
131145

132146
var labelTextBoxValue = new LabelTextBox
133147
{
134-
LabelText = "Value",
148+
Tag = "Value",
149+
LabelText = sbValueLabelText.ToString(),
135150
IsMandatory = false,
136151
};
137152

153+
if (!string.IsNullOrEmpty(valueLabelRegexPattern))
154+
{
155+
labelTextBoxValue.RegexPattern = valueLabelRegexPattern;
156+
}
157+
138158
if (updateItem is not null &&
139159
string.IsNullOrEmpty(updateItem.Template))
140160
{
141-
labelTextBoxValue.Text = updateItem.Value.ToString()!;
161+
var value = updateItem.Value.ToString()!;
162+
if (string.IsNullOrEmpty(valueLabelRegexPattern) &&
163+
Regex.IsMatch(value, RegexPatternConstants.Boolean.Strict, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture))
164+
{
165+
labelTextBoxValue.ValidationText = "True/False";
166+
labelTextBoxValue.RegexPattern = RegexPatternConstants.Boolean.Optional;
167+
}
168+
169+
labelTextBoxValue.Text = value;
142170
}
143171

144172
labelControls.Add(labelTextBoxValue);

src/Atc.Installer.Wpf.ComponentProvider/GlobalUsings.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
global using System.IO.Compression;
77
global using System.Security.AccessControl;
88
global using System.Text;
9+
global using System.Text.RegularExpressions;
910
global using System.Windows;
1011
global using System.Windows.Data;
1112
global using System.Windows.Documents;
@@ -22,6 +23,7 @@
2223
global using Atc.Installer.Wpf.ComponentProvider.Factories;
2324
global using Atc.Installer.Wpf.ComponentProvider.Messages;
2425
global using Atc.Installer.Wpf.ComponentProvider.Models;
26+
global using Atc.Installer.Wpf.ComponentProvider.ValueConverters;
2527
global using Atc.Installer.Wpf.ComponentProvider.ViewModels;
2628
global using Atc.Serialization;
2729
global using Atc.Wpf.Collections;

src/Atc.Installer.Wpf.ComponentProvider/Messages/UpdateApplicationOptionsMessage.cs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
namespace Atc.Installer.Wpf.ComponentProvider.Messages;
22

3-
[SuppressMessage("Minor Code Smell", "S2094:Classes should not be empty", Justification = "OK - used for MVVM message.")]
4-
public class UpdateApplicationOptionsMessage : MessageBase
3+
public class UpdateApplicationOptionsMessage(
4+
bool enableEditingMode,
5+
bool showOnlyBaseSettings) : MessageBase
56
{
6-
public UpdateApplicationOptionsMessage(
7-
bool enableEditingMode,
8-
bool showOnlyBaseSettings)
9-
{
10-
EnableEditingMode = enableEditingMode;
11-
ShowOnlyBaseSettings = showOnlyBaseSettings;
12-
}
7+
public bool EnableEditingMode { get; } = enableEditingMode;
138

14-
public bool EnableEditingMode { get; }
15-
16-
public bool ShowOnlyBaseSettings { get; }
9+
public bool ShowOnlyBaseSettings { get; } = showOnlyBaseSettings;
1710

1811
public override string ToString()
1912
=> $"{nameof(EnableEditingMode)}: {EnableEditingMode}, {nameof(ShowOnlyBaseSettings)}: {ShowOnlyBaseSettings}";

src/Atc.Installer.Wpf.ComponentProvider/Messages/UpdateDefaultApplicationSettingsMessage.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
namespace Atc.Installer.Wpf.ComponentProvider.Messages;
22

3-
public class UpdateDefaultApplicationSettingsMessage : MessageBase
3+
public class UpdateDefaultApplicationSettingsMessage(
4+
TriggerActionType triggerActionType,
5+
KeyValueTemplateItemViewModel keyValueTemplateItem)
6+
: MessageBase
47
{
5-
public UpdateDefaultApplicationSettingsMessage(
6-
TriggerActionType triggerActionType,
7-
KeyValueTemplateItemViewModel keyValueTemplateItem)
8-
{
9-
TriggerActionType = triggerActionType;
10-
KeyValueTemplateItem = keyValueTemplateItem;
11-
}
8+
public TriggerActionType TriggerActionType { get; } = triggerActionType;
129

13-
public TriggerActionType TriggerActionType { get; }
14-
15-
public KeyValueTemplateItemViewModel KeyValueTemplateItem { get; }
10+
public KeyValueTemplateItemViewModel KeyValueTemplateItem { get; } = keyValueTemplateItem;
1611

1712
public override string ToString()
1813
=> $"{nameof(TriggerActionType)}: {TriggerActionType}, {nameof(KeyValueTemplateItem)}: {KeyValueTemplateItem}";

0 commit comments

Comments
 (0)