Skip to content

Commit c458feb

Browse files
authored
Merge pull request #527 from LogExperts/highlightbackwardscompatibility
added backwards compatibility for hilightgroups in old settings files
2 parents cfae27e + 94d6481 commit c458feb

5 files changed

Lines changed: 109 additions & 20 deletions

File tree

src/LogExpert.Configuration/ConfigManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,8 @@ PathTooLongException or
817817

818818
private static void SaveHighlightGroupsAsJSON (FileInfo fileInfo, List<HighlightGroup> groups)
819819
{
820-
using StreamWriter sw = new(fileInfo.Create());
821-
JsonSerializer serializer = new();
822-
serializer.Serialize(sw, groups);
820+
string json = JsonConvert.SerializeObject(groups, Formatting.Indented);
821+
File.WriteAllText(fileInfo.FullName, json, System.Text.Encoding.UTF8);
823822
}
824823

825824
/// <summary>

src/LogExpert.Core/Config/Preferences.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,32 @@ namespace LogExpert.Core.Config;
88
[Serializable]
99
public class Preferences
1010
{
11+
12+
/// <summary>
13+
/// List of highlight groups for syntax highlighting and text coloring.
14+
/// </summary>
15+
/// <remarks>
16+
/// Supports legacy property name "hilightGroupList" (with typo) for backward compatibility.
17+
/// Old settings files using the incorrect spelling will be automatically imported.
18+
/// </remarks>
19+
[Newtonsoft.Json.JsonProperty("HighlightGroupList")]
20+
[System.Text.Json.Serialization.JsonPropertyName("HighlightGroupList")]
1121
public List<HighlightGroup> HighlightGroupList { get; set; } = [];
1222

23+
/// <summary>
24+
/// Legacy property for backward compatibility with old settings files that used the typo "hilightGroupList".
25+
/// This setter redirects data to the correct <see cref="HighlightGroupList"/> property.
26+
/// Will be removed in a future version once migration period is complete.
27+
/// </summary>
28+
[Obsolete("This property exists only for backward compatibility with old settings files. Use HighlightGroupList instead.")]
29+
[Newtonsoft.Json.JsonProperty("hilightGroupList")]
30+
[System.Text.Json.Serialization.JsonPropertyName("hilightGroupList")]
31+
public List<HighlightGroup> HilightGroupList
32+
{
33+
get => HighlightGroupList;
34+
set => HighlightGroupList = value ?? [];
35+
}
36+
1337
public bool PortableMode { get; set; }
1438

1539
/// <summary>

src/LogExpert.Core/Config/Settings.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Drawing;
22

33
using LogExpert.Core.Classes.Filter;
4+
using LogExpert.Core.Classes.Highlight;
5+
using LogExpert.Core.Entities;
46
using LogExpert.Entities;
57

68
namespace LogExpert.Core.Config;
@@ -34,6 +36,47 @@ public class Settings
3436

3537
public bool HideLineColumn { get; set; }
3638

39+
/// <summary>
40+
/// Legacy property for backward compatibility with old settings files that had hilightEntryList at root level.
41+
/// This property redirects data to Preferences.HighlightGroupList during import.
42+
/// Will be removed in a future version once migration period is complete.
43+
/// </summary>
44+
[Obsolete("This property exists only for backward compatibility with old settings files. Data is stored in Preferences.HighlightGroupList.")]
45+
[Newtonsoft.Json.JsonProperty("hilightEntryList")]
46+
[System.Text.Json.Serialization.JsonPropertyName("hilightEntryList")]
47+
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
48+
public List<HighlightEntry> HilightEntryList
49+
{
50+
get => null; // Never serialize this
51+
set
52+
{
53+
// This was likely empty in old files as entries were in groups
54+
// Keep for compatibility but likely unused
55+
}
56+
}
57+
58+
/// <summary>
59+
/// Legacy property for backward compatibility with old settings files that had hilightGroupList at root level.
60+
/// This property redirects data to Preferences.HighlightGroupList during import.
61+
/// Will be removed in a future version once migration period is complete.
62+
/// </summary>
63+
[Obsolete("This property exists only for backward compatibility with old settings files. Data is stored in Preferences.HighlightGroupList.")]
64+
[Newtonsoft.Json.JsonProperty("hilightGroupList")]
65+
[System.Text.Json.Serialization.JsonPropertyName("hilightGroupList")]
66+
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
67+
public List<HighlightGroup> HilightGroupList
68+
{
69+
get => null; // Never serialize this
70+
set
71+
{
72+
if (value != null && value.Count > 0)
73+
{
74+
Preferences ??= new Preferences();
75+
Preferences.HighlightGroupList = value;
76+
}
77+
}
78+
}
79+
3780
public bool IsMaximized { get; set; }
3881

3982
public string LastDirectory { get; set; }

src/LogExpert.Core/Entities/HighlightGroup.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,31 @@ public class HighlightGroup : ICloneable
99

1010
public string GroupName { get; set; } = string.Empty;
1111

12+
/// <summary>
13+
/// List of highlight entries defining text patterns and their formatting.
14+
/// </summary>
15+
/// <remarks>
16+
/// Supports legacy property name "hilightEntryList" (with typo) for backward compatibility.
17+
/// Old settings files using the incorrect spelling will be automatically imported.
18+
/// </remarks>
19+
[Newtonsoft.Json.JsonProperty("HighlightEntryList")]
20+
[System.Text.Json.Serialization.JsonPropertyName("HighlightEntryList")]
1221
public List<HighlightEntry> HighlightEntryList { get; set; } = [];
1322

23+
/// <summary>
24+
/// Legacy property for backward compatibility with old settings files that used the typo "hilightEntryList".
25+
/// This setter redirects data to the correct <see cref="HighlightEntryList"/> property.
26+
/// Will be removed in a future version once migration period is complete.
27+
/// </summary>
28+
[Obsolete("This property exists only for backward compatibility with old settings files. Use HighlightEntryList instead.")]
29+
[Newtonsoft.Json.JsonProperty("hilightEntryList")]
30+
[System.Text.Json.Serialization.JsonPropertyName("hilightEntryList")]
31+
public List<HighlightEntry> HilightEntryList
32+
{
33+
get => HighlightEntryList;
34+
set => HighlightEntryList = value ?? [];
35+
}
36+
1437
public object Clone ()
1538
{
1639
HighlightGroup clone = new()

src/PluginRegistry/PluginHashGenerator.Generated.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,36 @@ public static partial class PluginValidator
1010
{
1111
/// <summary>
1212
/// Gets pre-calculated SHA256 hashes for built-in plugins.
13-
/// Generated: 2026-01-22 07:56:13 UTC
13+
/// Generated: 2026-01-22 15:36:59 UTC
1414
/// Configuration: Release
1515
/// Plugin count: 22
1616
/// </summary>
1717
public static Dictionary<string, string> GetBuiltInPluginHashes()
1818
{
1919
return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
2020
{
21-
["AutoColumnizer.dll"] = "9C8F3E7BFBAA93A67FCBB8F6D55632468C57030EAE15FC3E96BC269F83E244A1",
21+
["AutoColumnizer.dll"] = "7BC68D6CAED29AA844E0C3D0EEF354DDD4CBFC4468343F060D6E09D80DC90B95",
2222
["BouncyCastle.Cryptography.dll"] = "E5EEAF6D263C493619982FD3638E6135077311D08C961E1FE128F9107D29EBC6",
2323
["BouncyCastle.Cryptography.dll (x86)"] = "E5EEAF6D263C493619982FD3638E6135077311D08C961E1FE128F9107D29EBC6",
24-
["CsvColumnizer.dll"] = "C526D416E88ED8EB59934C2CABD55E86C873C1D2822F160077B9D0A172E759CC",
25-
["CsvColumnizer.dll (x86)"] = "C526D416E88ED8EB59934C2CABD55E86C873C1D2822F160077B9D0A172E759CC",
26-
["DefaultPlugins.dll"] = "B37B0571F251C0689227C267E95A57D16F6EFD9FCE024E35A7499ED0977863A3",
27-
["FlashIconHighlighter.dll"] = "024F7D300FF3106E60FF9796CF40E477AC31E36706ADC285D9FB5276E872B0E5",
28-
["GlassfishColumnizer.dll"] = "D58B9D11609A76E5B515F758560DD984576B59DCDF9B80BC22FA4AF5F4384E68",
29-
["JsonColumnizer.dll"] = "6CB92960BEA2BFCFD971F753F288EDB75250FA0B6A42500847ED789361A86DF6",
30-
["JsonCompactColumnizer.dll"] = "786094F70FF7BD793D8B47CDFFA2F9794859240ED1DCDD369F6727CEB6BB627E",
31-
["Log4jXmlColumnizer.dll"] = "2C2521F0862409C5F67D7471C32608D4DD50221E7F393D7536A33CC1321C5B15",
32-
["LogExpert.Core.dll"] = "D7B4672FBD21BD9C0707C3D098ED6DC3B94FEFCA593FEB2A5B0D4729FC2278F0",
33-
["LogExpert.Resources.dll"] = "53281AD7771FA28D1CE64A3C4893196130681A22A741703EF980A1E5A31C140A",
24+
["CsvColumnizer.dll"] = "D67A6A7B0EAB65B5C352EAED26B89104BC057612279ECD7ADD34BBEE3830019E",
25+
["CsvColumnizer.dll (x86)"] = "D67A6A7B0EAB65B5C352EAED26B89104BC057612279ECD7ADD34BBEE3830019E",
26+
["DefaultPlugins.dll"] = "E0503BC7A1CE12E8F18F058C62AB84C2402733E76F9E871C163A3A7900841B5A",
27+
["FlashIconHighlighter.dll"] = "32510C6566AA4321EFD39190471F9622EED1934D4E415E73D176A150CD4963B5",
28+
["GlassfishColumnizer.dll"] = "D504BFF6EC14F54C073BF23778C8BB0513F6385B21A10363D6C4415E18ED724A",
29+
["JsonColumnizer.dll"] = "2C786E6C1E9917EDEB224720C8B4AC7F322A0F9489C07E44F5F62AB887801E79",
30+
["JsonCompactColumnizer.dll"] = "63E5AE492888DF52C0B5F4584F6CDD35FA8B2DDF8192C75A9DD662C2C4FEDD96",
31+
["Log4jXmlColumnizer.dll"] = "3E85454E4CFD2563F77B26A3BD7E1A6F85D6B7C0E96338B3FFED1B8BC472C8D7",
32+
["LogExpert.Core.dll"] = "B8977B248A9A11632B9632D2905A364F98F8625391DDCA40F76CF8CDA185EAE6",
33+
["LogExpert.Resources.dll"] = "43507497CCBECB8E9A3285A7E837A4B8C88679FC030CF4AA7B2611B203A3AB9C",
3434
["Microsoft.Extensions.DependencyInjection.Abstractions.dll"] = "67FA4325000DB017DC0C35829B416F024F042D24EFB868BCF17A895EE6500A93",
3535
["Microsoft.Extensions.DependencyInjection.Abstractions.dll (x86)"] = "67FA4325000DB017DC0C35829B416F024F042D24EFB868BCF17A895EE6500A93",
3636
["Microsoft.Extensions.Logging.Abstractions.dll"] = "BB853130F5AFAF335BE7858D661F8212EC653835100F5A4E3AA2C66A4D4F685D",
3737
["Microsoft.Extensions.Logging.Abstractions.dll (x86)"] = "BB853130F5AFAF335BE7858D661F8212EC653835100F5A4E3AA2C66A4D4F685D",
38-
["RegexColumnizer.dll"] = "E58187975AC91B7CF1339511C741C5D571AA015C9DAB0E9694579EAABEEEE69F",
39-
["SftpFileSystem.dll"] = "65A6149D52DB7A7089FDAFAE6DA78B7197025BBB04C56EC466F3FEF73804B73A",
40-
["SftpFileSystem.dll (x86)"] = "6D455A9F064804CB7A0639C210629B008B75EDABC6DB30666A7230A14AE4C0B4",
41-
["SftpFileSystem.Resources.dll"] = "F9045AA68358565F6310B22C960240BDEFFE338888368AEC1CF4B07B8A149F3E",
42-
["SftpFileSystem.Resources.dll (x86)"] = "F9045AA68358565F6310B22C960240BDEFFE338888368AEC1CF4B07B8A149F3E",
38+
["RegexColumnizer.dll"] = "0E6C500586C79D0280973B5D2A69AC0DB16FCF1AB963C6016965AE6CE3DB1103",
39+
["SftpFileSystem.dll"] = "A2C0E76211A0DE50F0C9B2B9BD1B97519ED390382179ACB73AED232245F42D2B",
40+
["SftpFileSystem.dll (x86)"] = "453EA3A17F9F6CAE24C76C6368264C0FA6745DC0FC8A2E6DAD86B127227A02E5",
41+
["SftpFileSystem.Resources.dll"] = "A1185922C0FF4ED0E8CE734FDA6B238ADE7C4DD4C8DC3811C41F618FCD4D4C5E",
42+
["SftpFileSystem.Resources.dll (x86)"] = "A1185922C0FF4ED0E8CE734FDA6B238ADE7C4DD4C8DC3811C41F618FCD4D4C5E",
4343

4444
};
4545
}

0 commit comments

Comments
 (0)