From 0f002a4c2b16fe1c02eda66f18bf45ed7c258e5d Mon Sep 17 00:00:00 2001 From: Lior Banai Date: Thu, 16 Nov 2023 09:13:59 +0200 Subject: [PATCH] NET8 --- .editorconfig | 1 + .github/workflows/dotnet-core-desktop.yml | 6 +- ...alogy.LogViewer.PowerToys.UnitTests.csproj | 2 +- .../MessageHandlerForTesting.cs | 4 +- .../{UnitTests.cs => Tests.cs} | 6 +- Analogy.LogViewer.PowerToys.sln | 12 +++- .../Analogy.LogViewer.PowerToys.csproj | 34 +---------- Analogy.LogViewer.PowerToys/ChangeLogList.cs | 13 ++-- .../IAnalogy/DataProvidersFactory.cs | 8 +-- .../IAnalogy/DownloadInformation.cs | 2 +- .../IAnalogy/OfflineDataProvider.cs | 14 ++--- .../PowerToysRegexOfflineDataProvider.cs | 5 +- .../IAnalogy/PrimaryFactory.cs | 10 ++- .../Managers/UserSettingsManager.cs | 13 ++-- .../Parser/PlainLogFileParser.cs | 10 +-- .../Parser/PlainTextLogFileLoader.cs | 11 ++-- .../PowerToysSettings.cs | 2 +- Analogy.LogViewer.PowerToys/SettingsForm.cs | 3 +- BannedSymbols.txt | 9 +++ Directory.Build.props | 61 +++++++++++++++++++ 20 files changed, 132 insertions(+), 94 deletions(-) rename Analogy.LogViewer.PowerToys.UnitTests/{UnitTests.cs => Tests.cs} (95%) create mode 100644 BannedSymbols.txt create mode 100644 Directory.Build.props diff --git a/.editorconfig b/.editorconfig index fa05938..0f27dd6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -273,6 +273,7 @@ dotnet_diagnostic.SA1122.severity = suggestion dotnet_diagnostic.SA1108.severity = silent dotnet_diagnostic.SA1012.severity = error dotnet_diagnostic.SA1500.severity = error +dotnet_diagnostic.SA1316.severity = error [*.{cs,vb}] dotnet_style_operator_placement_when_wrapping = beginning_of_line diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml index 1c0d2f1..7e0fc14 100644 --- a/.github/workflows/dotnet-core-desktop.yml +++ b/.github/workflows/dotnet-core-desktop.yml @@ -29,13 +29,13 @@ jobs: # Install the .NET Core workload - name: Install .NET Core - uses: actions/setup-dotnet@v3.0.3 + uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.1.3 + uses: microsoft/setup-msbuild@v1.3.1 # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application diff --git a/Analogy.LogViewer.PowerToys.UnitTests/Analogy.LogViewer.PowerToys.UnitTests.csproj b/Analogy.LogViewer.PowerToys.UnitTests/Analogy.LogViewer.PowerToys.UnitTests.csproj index b7f53f8..a5e9f84 100644 --- a/Analogy.LogViewer.PowerToys.UnitTests/Analogy.LogViewer.PowerToys.UnitTests.csproj +++ b/Analogy.LogViewer.PowerToys.UnitTests/Analogy.LogViewer.PowerToys.UnitTests.csproj @@ -1,7 +1,7 @@ - net6.0-windows + net8.0-windows false diff --git a/Analogy.LogViewer.PowerToys.UnitTests/MessageHandlerForTesting.cs b/Analogy.LogViewer.PowerToys.UnitTests/MessageHandlerForTesting.cs index 58f90a6..f4701f8 100644 --- a/Analogy.LogViewer.PowerToys.UnitTests/MessageHandlerForTesting.cs +++ b/Analogy.LogViewer.PowerToys.UnitTests/MessageHandlerForTesting.cs @@ -4,7 +4,7 @@ namespace Analogy.LogViewer.PowerToys.UnitTests { - class MessageHandlerForTesting : ILogMessageCreatedHandler + public class MessageHandlerForTesting : ILogMessageCreatedHandler { private List messages; public MessageHandlerForTesting() @@ -29,4 +29,4 @@ public void ReportFileReadProgress(AnalogyFileReadProgress progress) public bool ForceNoFileCaching { get; set; } public bool DoNotAddToRecentHistory { get; set; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys.UnitTests/UnitTests.cs b/Analogy.LogViewer.PowerToys.UnitTests/Tests.cs similarity index 95% rename from Analogy.LogViewer.PowerToys.UnitTests/UnitTests.cs rename to Analogy.LogViewer.PowerToys.UnitTests/Tests.cs index 011a86b..1edaf84 100644 --- a/Analogy.LogViewer.PowerToys.UnitTests/UnitTests.cs +++ b/Analogy.LogViewer.PowerToys.UnitTests/Tests.cs @@ -7,7 +7,7 @@ namespace Analogy.LogViewer.PowerToys.UnitTests { [TestClass] - public class UnitTests + public class Tests { [TestMethod] public async Task TestMethod1() @@ -16,8 +16,6 @@ public async Task TestMethod1() await parser.InitializeDataProvider(null); var results = await parser.Process("2020-10-03.txt", new CancellationToken(), new MessageHandlerForTesting()); Assert.IsTrue(results.Count() == 61); - - } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys.sln b/Analogy.LogViewer.PowerToys.sln index 9f5e63f..2822539 100644 --- a/Analogy.LogViewer.PowerToys.sln +++ b/Analogy.LogViewer.PowerToys.sln @@ -1,12 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30517.126 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.PowerToys", "Analogy.LogViewer.PowerToys\Analogy.LogViewer.PowerToys.csproj", "{EAF4F4EA-619E-4F93-8394-DCE68564FEE3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.PowerToys.UnitTests", "Analogy.LogViewer.PowerToys.UnitTests\Analogy.LogViewer.PowerToys.UnitTests.csproj", "{566038EC-6A3E-4B13-AD8B-FB17A02337CB}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B27D6FFC-0C5C-4878-977D-40BD42F7C184}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + Directory.Build.props = Directory.Build.props + .github\workflows\dotnet-core-desktop.yml = .github\workflows\dotnet-core-desktop.yml + nuget.config = nuget.config + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Analogy.LogViewer.PowerToys/Analogy.LogViewer.PowerToys.csproj b/Analogy.LogViewer.PowerToys/Analogy.LogViewer.PowerToys.csproj index b4084be..e5d2ce3 100644 --- a/Analogy.LogViewer.PowerToys/Analogy.LogViewer.PowerToys.csproj +++ b/Analogy.LogViewer.PowerToys/Analogy.LogViewer.PowerToys.csproj @@ -2,29 +2,16 @@ Library - net7.0-windows;net6.0-windows;net48;net471 - true - true - true - snupkg - true - true + net8.0-windows;net7.0-windows;net6.0-windows;net48;net471 Lior Banai Analogy PowerToys log parser - Lior Banai © 2020-2023 - MIT + Lior Banai © 2020-2024 https://github.com/Analogy-LogViewer/Analogy.LogViewer.PowerToys https://github.com/Analogy-LogViewer/Analogy.LogViewer.PowerToys - git Analogy PowerToys log parser - - true - 0.15.0 + 0.16.0 Analogy.LogViewer - true AnalogyPowerToys.png - enable - latest @@ -41,24 +28,9 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - True diff --git a/Analogy.LogViewer.PowerToys/ChangeLogList.cs b/Analogy.LogViewer.PowerToys/ChangeLogList.cs index cccf2d4..bf95f37 100644 --- a/Analogy.LogViewer.PowerToys/ChangeLogList.cs +++ b/Analogy.LogViewer.PowerToys/ChangeLogList.cs @@ -1,16 +1,17 @@ -using System; +using Analogy.Interfaces; +using System; using System.Collections.Generic; -using Analogy.Interfaces; namespace Analogy.LogViewer.PowerToys { - static class ChangeLogList + public static class ChangeLogList { public static IEnumerable GetChangeLog() { - return new List{ - new AnalogyChangeLog("Initial version", AnalogChangeLogType.None, "Lior Banai", new DateTime(2020, 10, 03), "") + return new List + { + new AnalogyChangeLog("Initial version", AnalogChangeLogType.None, "Lior Banai", new DateTime(2020, 10, 03), ""), }; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/IAnalogy/DataProvidersFactory.cs b/Analogy.LogViewer.PowerToys/IAnalogy/DataProvidersFactory.cs index 793da05..58211aa 100644 --- a/Analogy.LogViewer.PowerToys/IAnalogy/DataProvidersFactory.cs +++ b/Analogy.LogViewer.PowerToys/IAnalogy/DataProvidersFactory.cs @@ -1,6 +1,6 @@ -using System; +using Analogy.Interfaces; +using System; using System.Collections.Generic; -using Analogy.Interfaces; namespace Analogy.LogViewer.PowerToys.IAnalogy { @@ -11,7 +11,7 @@ public class DataProvidersFactory : LogViewer.Template.DataProvidersFactory public override IEnumerable DataProviders { get; set; } = new List { //new PowerToysRegexOfflineDataProvider(), - new OfflineDataProvider() + new OfflineDataProvider(), }; } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/IAnalogy/DownloadInformation.cs b/Analogy.LogViewer.PowerToys/IAnalogy/DownloadInformation.cs index f27701c..73663c9 100644 --- a/Analogy.LogViewer.PowerToys/IAnalogy/DownloadInformation.cs +++ b/Analogy.LogViewer.PowerToys/IAnalogy/DownloadInformation.cs @@ -33,4 +33,4 @@ public override string InstalledVersionNumber } } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/IAnalogy/OfflineDataProvider.cs b/Analogy.LogViewer.PowerToys/IAnalogy/OfflineDataProvider.cs index ed34a86..ba47bd9 100644 --- a/Analogy.LogViewer.PowerToys/IAnalogy/OfflineDataProvider.cs +++ b/Analogy.LogViewer.PowerToys/IAnalogy/OfflineDataProvider.cs @@ -27,15 +27,15 @@ public OfflineDataProvider() LogParserSettings = new SplitterLogParserSettings { Splitter = "|", - SupportedFilesExtensions = new List {"*.txt"}, + SupportedFilesExtensions = new List { "*.txt"}, Maps = new Dictionary { - {0, AnalogyLogMessagePropertyName.Date}, - {1, AnalogyLogMessagePropertyName.Level}, - {2, AnalogyLogMessagePropertyName.Source}, - {3, AnalogyLogMessagePropertyName.Text} + { 0, AnalogyLogMessagePropertyName.Date}, + { 1, AnalogyLogMessagePropertyName.Level}, + { 2, AnalogyLogMessagePropertyName.Source}, + { 3, AnalogyLogMessagePropertyName.Text}, }, - IsConfigured = true + IsConfigured = true, }; parser = new PlainTextLogFileLoader(LogParserSettings); } @@ -43,4 +43,4 @@ public override Task> Process(string fileName, C ILogMessageCreatedHandler messagesHandler) => parser.Process(fileName, token, messagesHandler); } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/IAnalogy/PowerToysRegexOfflineDataProvider.cs b/Analogy.LogViewer.PowerToys/IAnalogy/PowerToysRegexOfflineDataProvider.cs index 4f52b21..2ff9936 100644 --- a/Analogy.LogViewer.PowerToys/IAnalogy/PowerToysRegexOfflineDataProvider.cs +++ b/Analogy.LogViewer.PowerToys/IAnalogy/PowerToysRegexOfflineDataProvider.cs @@ -20,7 +20,6 @@ public class PowerToysRegexOfflineDataProvider : RegexOfflineDataProvider public override Image? LargeImage { get; set; } public override Image? SmallImage { get; set; } - public override Task InitializeDataProvider(ILogger logger) { RegexParser.Managers.UserSettingsManager.UserSettings.Settings.FileOpenDialogFilters = "Plain log text file (*.txt)|*.txt"; @@ -56,7 +55,6 @@ public RemoveLeadingNewLine(ILogMessageCreatedHandler nominalMessagesHandler) DoNotAddToRecentHistory = _messagesHandler.DoNotAddToRecentHistory; } - public void AppendMessage(IAnalogyLogMessage message, string dataSource) { if (message.Text.StartsWith(Environment.NewLine)) @@ -78,7 +76,6 @@ public void AppendMessages(List messages, string dataSource) _messagesHandler.AppendMessages(messages, dataSource); } - } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/IAnalogy/PrimaryFactory.cs b/Analogy.LogViewer.PowerToys/IAnalogy/PrimaryFactory.cs index 03910af..6c141e6 100644 --- a/Analogy.LogViewer.PowerToys/IAnalogy/PrimaryFactory.cs +++ b/Analogy.LogViewer.PowerToys/IAnalogy/PrimaryFactory.cs @@ -1,8 +1,8 @@ -using System; +using Analogy.Interfaces; +using Analogy.LogViewer.PowerToys.Properties; +using System; using System.Collections.Generic; using System.Drawing; -using Analogy.Interfaces; -using Analogy.LogViewer.PowerToys.Properties; namespace Analogy.LogViewer.PowerToys.IAnalogy { @@ -16,7 +16,5 @@ public class PrimaryFactory : Analogy.LogViewer.Template.PrimaryFactory public override string About { get; set; } = "Analogy Log Parser for Microsoft PowerToys"; public override Image? SmallImage { get; set; } = Resources.powertoys16x16; public override Image? LargeImage { get; set; } = Resources.powertoys32x32; - - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/Managers/UserSettingsManager.cs b/Analogy.LogViewer.PowerToys/Managers/UserSettingsManager.cs index a897d0a..ad0fd28 100644 --- a/Analogy.LogViewer.PowerToys/Managers/UserSettingsManager.cs +++ b/Analogy.LogViewer.PowerToys/Managers/UserSettingsManager.cs @@ -1,8 +1,8 @@ -using System; -using System.IO; -using Analogy.LogViewer.Template.Managers; +using Analogy.LogViewer.Template.Managers; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using System; +using System.IO; namespace Analogy.LogViewer.PowerToys.Managers { @@ -14,7 +14,6 @@ public class UserSettingsManager public string PowerToysSettingsFileSetting { get; private set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Analogy.LogViewer", "AnalogyPowerToysSettings.json"); public PowerToysSettings Settings { get; set; } - public UserSettingsManager() { if (File.Exists(PowerToysSettingsFileSetting)) @@ -23,7 +22,7 @@ public UserSettingsManager() { var settings = new JsonSerializerSettings { - ObjectCreationHandling = ObjectCreationHandling.Replace + ObjectCreationHandling = ObjectCreationHandling.Replace, }; string data = File.ReadAllText(PowerToysSettingsFileSetting); Settings = JsonConvert.DeserializeObject(data, settings)!; @@ -32,14 +31,12 @@ public UserSettingsManager() { LogManager.Instance.LogError(ex, "Error loading user setting file", ex, "Analogy Power Toys Settings"); Settings = new PowerToysSettings(); - } } else { Settings = new PowerToysSettings(); } - } public void Save() @@ -52,8 +49,6 @@ public void Save() { LogManager.Instance.LogError(e, "Error saving settings: " + e.Message, e, "Analogy Power Toys Settings"); } - - } } } \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/Parser/PlainLogFileParser.cs b/Analogy.LogViewer.PowerToys/Parser/PlainLogFileParser.cs index 8a7ce49..92cb85e 100644 --- a/Analogy.LogViewer.PowerToys/Parser/PlainLogFileParser.cs +++ b/Analogy.LogViewer.PowerToys/Parser/PlainLogFileParser.cs @@ -1,14 +1,14 @@ -using System; +using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; -using Analogy.Interfaces; -using Analogy.Interfaces.DataTypes; namespace Analogy.LogViewer.PowerToys.Parser { - class PlainLogFileParser + public class PlainLogFileParser { private readonly ISplitterLogParserSettings _logFileSettings; public readonly string[] splitters; @@ -34,4 +34,4 @@ public AnalogyLogMessage Parse(string line) return AnalogyLogMessage.Parse(map); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/Parser/PlainTextLogFileLoader.cs b/Analogy.LogViewer.PowerToys/Parser/PlainTextLogFileLoader.cs index cdf9f79..7780576 100644 --- a/Analogy.LogViewer.PowerToys/Parser/PlainTextLogFileLoader.cs +++ b/Analogy.LogViewer.PowerToys/Parser/PlainTextLogFileLoader.cs @@ -25,7 +25,7 @@ public async Task> Process(string fileName, Canc AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None") { Source = "Analogy", - Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName + Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName, }; messagesHandler.AppendMessage(empty, GetFileNameAsDataSource(fileName)); return new List { empty }; @@ -36,7 +36,7 @@ public async Task> Process(string fileName, Canc AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None") { Source = "Analogy", - Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName + Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName, }; messagesHandler.AppendMessage(empty, GetFileNameAsDataSource(fileName)); return new List { empty }; @@ -47,7 +47,7 @@ public async Task> Process(string fileName, Canc AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None") { Source = "Analogy", - Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName + Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName, }; messagesHandler.AppendMessage(empty, GetFileNameAsDataSource(fileName)); return new List { empty }; @@ -94,7 +94,6 @@ public async Task> Process(string fileName, Canc if (entry != null) { messages.Add(entry); - } } messagesHandler.AppendMessages(messages, fileName); @@ -106,7 +105,7 @@ public async Task> Process(string fileName, Canc AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None") { Source = "Analogy", - Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName + Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName, }; messagesHandler.AppendMessage(empty, GetFileNameAsDataSource(fileName)); return new List { empty }; @@ -119,4 +118,4 @@ private static string GetFileNameAsDataSource(string fileName) return fileName.Equals(file) ? fileName : $"{file} ({fileName})"; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/PowerToysSettings.cs b/Analogy.LogViewer.PowerToys/PowerToysSettings.cs index 9abadbf..fd65667 100644 --- a/Analogy.LogViewer.PowerToys/PowerToysSettings.cs +++ b/Analogy.LogViewer.PowerToys/PowerToysSettings.cs @@ -3,4 +3,4 @@ public class PowerToysSettings { } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.PowerToys/SettingsForm.cs b/Analogy.LogViewer.PowerToys/SettingsForm.cs index b1a1a5e..385afdf 100644 --- a/Analogy.LogViewer.PowerToys/SettingsForm.cs +++ b/Analogy.LogViewer.PowerToys/SettingsForm.cs @@ -8,6 +8,5 @@ public SettingsForm() { InitializeComponent(); } - } -} +} \ No newline at end of file diff --git a/BannedSymbols.txt b/BannedSymbols.txt new file mode 100644 index 0000000..26002bb --- /dev/null +++ b/BannedSymbols.txt @@ -0,0 +1,9 @@ +#https://github.com/dotnet/csharplang/blob/main/spec/documentation-comments.md#id-string-format + +M:System.String.ToLower;Use ToLowerInvariant instead +M:System.String.ToUpper;Use ToUpperInvariant instead + +F:System.StringComparison.CurrentCulture;Consider using Ordinal +F:System.StringComparison.CurrentCultureIgnoreCase;Consider using OrdinalIgnoreCase +F:System.StringComparison.InvariantCurrent;Consider using Ordinal +F:System.StringComparison.InvariantCurrentIgnoreCase;Consider using OrdinalIgnoreCase diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..92e4444 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,61 @@ + + + true + true + True + snupkg + true + true + true + MIT + true + False + git + portable + + + enable + latest + + + $(DefineContants);DEBUG + false + + + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file