From 90a33ee2451fde433d894fec02d8e58c4ec29149 Mon Sep 17 00:00:00 2001 From: Lior Banai Date: Thu, 16 Nov 2023 12:19:06 +0200 Subject: [PATCH] NET8 --- .editorconfig | 1 + .github/workflows/dotnet-core-desktop.yml | 6 +- Analogy.Example.sln | 10 ++- ...Analogy.LogViewer.Example.UnitTests.csproj | 2 +- .../UnitTest1.cs | 2 +- .../Analogy.LogViewer.Example.csproj | 41 +++---------- .../IAnalogy/ExampleAnalogyImages.cs | 4 +- .../IAnalogy/ExampleDataProviderFactory.cs | 9 +-- .../IAnalogy/ExampleDownloadInformation.cs | 4 +- .../IAnalogy/ExampleOnDemandPlotting.cs | 11 ++-- .../ExampleOnDemandPlottingFactory.cs | 3 +- .../IAnalogy/ExamplePlotting.cs | 8 ++- .../IAnalogy/ExamplePolicyEnforcer.cs | 2 +- .../IAnalogy/ExampleUserControl.cs | 17 +++--- .../IAnalogy/ExampleUserControlUC.cs | 3 +- .../IAnalogy/ExampleUserSettingsFactory.cs | 18 +++--- .../IAnalogy/ExtensionExample.cs | 25 ++++---- .../IAnalogy/OfflineExampleDataProvider.cs | 16 +++-- .../IAnalogy/OnlineExampleDataProvider.cs | 34 +++++------ .../IAnalogy/PrimaryFactory.cs | 22 +++---- .../IAnalogy/ServerSidePagingProvider.cs | 21 +++---- .../IAnalogy/UserControlExtensionExample.cs | 2 +- .../OnDemandPlottingContainer.cs | 8 +-- BannedSymbols.txt | 9 +++ Directory.Build.props | 61 +++++++++++++++++++ 25 files changed, 188 insertions(+), 151 deletions(-) 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 cda3121..4c071b3 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.Example.sln b/Analogy.Example.sln index bc7c9cd..796cc11 100644 --- a/Analogy.Example.sln +++ b/Analogy.Example.sln @@ -4,7 +4,15 @@ VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.Example", "Analogy.LogViewer.Example\Analogy.LogViewer.Example.csproj", "{69EF9461-D518-457B-A354-B8A4407F80FF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analogy.LogViewer.Example.UnitTests", "Analogy.LogViewer.Example.UnitTests\Analogy.LogViewer.Example.UnitTests.csproj", "{1F0A036F-B1E0-4873-B87C-64B1E8FE8672}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.Example.UnitTests", "Analogy.LogViewer.Example.UnitTests\Analogy.LogViewer.Example.UnitTests.csproj", "{1F0A036F-B1E0-4873-B87C-64B1E8FE8672}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D4A0EAC0-DF24-43A5-9EA6-D4F61DAFC7F9}" + 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 diff --git a/Analogy.LogViewer.Example.UnitTests/Analogy.LogViewer.Example.UnitTests.csproj b/Analogy.LogViewer.Example.UnitTests/Analogy.LogViewer.Example.UnitTests.csproj index 14072ec..dae8182 100644 --- a/Analogy.LogViewer.Example.UnitTests/Analogy.LogViewer.Example.UnitTests.csproj +++ b/Analogy.LogViewer.Example.UnitTests/Analogy.LogViewer.Example.UnitTests.csproj @@ -1,7 +1,7 @@ - net7.0-windows + net8.0-windows false diff --git a/Analogy.LogViewer.Example.UnitTests/UnitTest1.cs b/Analogy.LogViewer.Example.UnitTests/UnitTest1.cs index 5375af9..30d73e0 100644 --- a/Analogy.LogViewer.Example.UnitTests/UnitTest1.cs +++ b/Analogy.LogViewer.Example.UnitTests/UnitTest1.cs @@ -10,4 +10,4 @@ public class UnitTest1 //{ //} } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/Analogy.LogViewer.Example.csproj b/Analogy.LogViewer.Example/Analogy.LogViewer.Example.csproj index 81a2729..b9e5f6e 100644 --- a/Analogy.LogViewer.Example/Analogy.LogViewer.Example.csproj +++ b/Analogy.LogViewer.Example/Analogy.LogViewer.Example.csproj @@ -1,55 +1,28 @@ - net7.0-windows;net6.0-windows;net48;net471 - true - true - true - snupkg - true - true - 5.0.3 + net8.0-windows;net7.0-windows;net6.0-windows;net48;net471 + 6.0.0 Lior Banai Analogy.LogViewer Analogy.LogViewer.Example Analogy.LogViewer.Example - true - Lior Banai © 2020-2023 + Lior Banai © 2020-2024 MIT https://github.com/Analogy-LogViewer/Analogy.LogViewer.Example https://github.com/Analogy-LogViewer/Analogy.LogViewer.Example - git icon.png - Example implementation of Analogy Log Viewer Data Provider Example implementation of Analogy Log Viewer Data Provider - true - enable - latest - - - - - 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.Example/IAnalogy/ExampleAnalogyImages.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleAnalogyImages.cs index 158dbfc..4272434 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleAnalogyImages.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleAnalogyImages.cs @@ -4,7 +4,5 @@ namespace Analogy.LogViewer.Example.IAnalogy { public class ExampleAnalogyImages : AnalogyImages { - } -} - +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleDataProviderFactory.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleDataProviderFactory.cs index 1283875..8051f54 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleDataProviderFactory.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleDataProviderFactory.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using Analogy.Interfaces; +using Analogy.Interfaces; using Analogy.LogViewer.Template; +using System; +using System.Collections.Generic; namespace Analogy.LogViewer.Example.IAnalogy { @@ -15,10 +15,11 @@ public class ExampleDataProviderFactory : DataProvidersFactory //add 2 "real time data providers" new OnlineExampleDataProvider("Online Data Provider 1", new Guid("6642B160-F992-4120-B688-B02DE2E83256")), new OnlineExampleDataProvider("Online Data Provider 2", new Guid("5AB690DC-545B-4150-B2CD-2534B2ACBF82")), + //add 2 "offline data providers" new OfflineExampleDataProvider("Offline Data Provider 1", new Guid("2BFC1602-17EF-447D-8DDC-8A00F46C1CE1")), new OfflineExampleDataProvider("Offline Data Provider 2", new Guid("B22D4BD1-10D7-460B-ADCE-849E73BCA91D")), new ServerSidePagingProvider(), }; } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleDownloadInformation.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleDownloadInformation.cs index 1742ddf..96fd19f 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleDownloadInformation.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleDownloadInformation.cs @@ -23,6 +23,7 @@ public override string InstalledVersionNumber { return _installedVersionNumber; } + Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); _installedVersionNumber = fvi.FileVersion; @@ -33,6 +34,5 @@ public override string InstalledVersionNumber public override string? LatestVersionNumber { get; set; } public override TargetFrameworkAttribute CurrentFrameworkAttribute { get; set; } = (TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttribute(typeof(TargetFrameworkAttribute)); protected override string RepositoryURL { get; set; } = "https://api.github.com/repos/Analogy-LogViewer/Analogy.LogViewer.Example"; - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlotting.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlotting.cs index d54b140..aea8e51 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlotting.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlotting.cs @@ -11,11 +11,10 @@ namespace Analogy.LogViewer.Example.IAnalogy { public class ExampleOnDemandPlotting : IAnalogyOnDemandPlotting { - public Guid Id { get; } = new Guid("bb38ccb7-8625-4b22-a33c-50a3cbd1e741"); public event EventHandler<(Guid Id, IEnumerable PointsData)> OnNewPointsData; private Timer simulateData; - int counter; + private int counter; private IAnalogyOnDemandPlottingInteractor Interactor { get; set; } public Task InitializeOnDemandPlotting(IAnalogyOnDemandPlottingInteractor onDemandPlottingInteractor, ILogger logger) { @@ -28,7 +27,6 @@ public Task InitializeOnDemandPlotting(IAnalogyOnDemandPlottingInteractor onDema return Task.CompletedTask; } - private void SimulateData_Tick(object sender, EventArgs e) { var now = DateTime.Now; @@ -39,8 +37,7 @@ private void SimulateData_Tick(object sender, EventArgs e) counter++; } - - double GenerateValue(double x) { return Math.Sin(x / 1000.0) * 3 * x + x / 2 + 5; } + private double GenerateValue(double x) { return Math.Sin(x / 1000.0) * 3 * x + x / 2 + 5; } public void StartPlotting() => simulateData.Enabled = true; @@ -50,6 +47,7 @@ public void ShowPlot() { Interactor.ShowPlot(Id, "Example", AnalogyOnDemandPlottingStartupType.TabbedWindow); } + public void ClosePlot() { Interactor.ClosePlot(Id); @@ -59,6 +57,7 @@ public void RemoveSeriesFromPlot(string seriesName) { Interactor.RemoveSeriesFromPlot(Id, seriesName); } + public void ClearSeriesData(string seriesNameToClear) { Interactor.ClearSeriesData(Id, seriesNameToClear); @@ -74,4 +73,4 @@ public void HidePlot() Interactor.ClosePlot(Id); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlottingFactory.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlottingFactory.cs index 092370a..aa257f8 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlottingFactory.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleOnDemandPlottingFactory.cs @@ -7,7 +7,6 @@ namespace Analogy.LogViewer.Example.IAnalogy { public class ExampleOnDemandPlottingFactory : IAnalogyOnDemandPlottingFactory { - public Guid Id { get; set; } = new Guid("4f59de24-aaab-4de0-9269-ef681f8f3ee6"); public string Title { get; set; } = "on Demand Plots Example"; public List OnDemandPlottingGenerators { get; set; } @@ -26,4 +25,4 @@ public void AddedOnDemandPlottingGenerator(IAnalogyOnDemandPlotting plotGenerato OnAddedOnDemandPlottingGenerator?.Invoke(this, plotGenerator); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExamplePlotting.cs b/Analogy.LogViewer.Example/IAnalogy/ExamplePlotting.cs index c4ed15c..92c5fb7 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExamplePlotting.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExamplePlotting.cs @@ -16,7 +16,7 @@ public class ExamplePlotting : IAnalogyPlotting public Guid FactoryId { get; set; } = PrimaryFactory.Id; public string Title { get; set; } = "Example real time plotting"; private Timer simulateData; - int counter; + private int counter; public Task InitializePlotting(IAnalogyPlottingInteractor uiInteractor, ILogger logger) { simulateData = new Timer(); @@ -31,6 +31,7 @@ public Task StartPlotting() simulateData.Enabled = true; return Task.CompletedTask; } + public Task StopPlotting() { simulateData.Enabled = false; @@ -42,6 +43,7 @@ public Task StopPlotting() yield return ("series1", AnalogyPlottingSeriesType.Line); yield return ("series2", AnalogyPlottingSeriesType.Line); } + private void SimulateData_Tick(object sender, EventArgs e) { var now = DateTime.Now; @@ -51,7 +53,7 @@ private void SimulateData_Tick(object sender, EventArgs e) OnNewPointData?.Invoke(this, d2); counter++; } - double GenerateValue(double x) { return Math.Sin(x / 1000.0) * 3 * x + x / 2 + 5; } + private double GenerateValue(double x) { return Math.Sin(x / 1000.0) * 3 * x + x / 2 + 5; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExamplePolicyEnforcer.cs b/Analogy.LogViewer.Example/IAnalogy/ExamplePolicyEnforcer.cs index e3516f6..20d6392 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExamplePolicyEnforcer.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExamplePolicyEnforcer.cs @@ -4,4 +4,4 @@ public class ExamplePolicyEnforcer : Template.AnalogyPolicyEnforcer { public override bool DisableUpdates { get; set; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleUserControl.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleUserControl.cs index e51b5f4..a911a1b 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleUserControl.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleUserControl.cs @@ -1,14 +1,14 @@ -using System; +using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; +using Analogy.Interfaces.Factories; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using Analogy.Interfaces; -using Analogy.Interfaces.DataTypes; -using Analogy.Interfaces.Factories; -using Microsoft.Extensions.Logging; namespace Analogy.LogViewer.Example.IAnalogy { @@ -18,8 +18,11 @@ public class ExampleUserControlFactory : IAnalogyCustomUserControlsFactory public string Title { get; set; } = "User Control Examples"; public IEnumerable UserControls { get; } = new List - {new ExampleUserControl()}; + { + new ExampleUserControl(), + }; } + public class ExampleUserControl :IAnalogyCustomUserControl { public Task InitializeUserControl(Control hostingControl, ILogger logger) @@ -39,4 +42,4 @@ public Task UserControlRemoved() public string Title { get; set; } = "Example User Control"; public AnalogyToolTip? ToolTip { get; set; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleUserControlUC.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleUserControlUC.cs index e6d2e1b..5cdd14f 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleUserControlUC.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleUserControlUC.cs @@ -38,7 +38,6 @@ private void btnGeneratorHide_Click(object sender, EventArgs e) private void btnStopPlotting_Click(object sender, EventArgs e) { p.StopPlotting(); - } private void btnShowPlot_Click(object sender, EventArgs e) @@ -46,4 +45,4 @@ private void btnShowPlot_Click(object sender, EventArgs e) p.ShowPlot(); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExampleUserSettingsFactory.cs b/Analogy.LogViewer.Example/IAnalogy/ExampleUserSettingsFactory.cs index 81cf5f4..0df26b1 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExampleUserSettingsFactory.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExampleUserSettingsFactory.cs @@ -1,15 +1,15 @@ -using System; +using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; +using Analogy.LogViewer.Example.Properties; +using Analogy.LogViewer.Template; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using Analogy.Interfaces; -using Analogy.Interfaces.DataTypes; -using Analogy.LogViewer.Example.Properties; -using Analogy.LogViewer.Template; -using Microsoft.Extensions.Logging; namespace Analogy.LogViewer.Example.IAnalogy { @@ -21,8 +21,6 @@ public class ExampleUserSettingsFactory:TemplateUserSettingsFactory public override string Title { get; set; } = "Example User Settings"; public override Image? SmallImage { get; set; } = Resources.Analogy_image_16x16; public override Image? LargeImage { get; set; } = Resources.Analogy_image_32x32; - - public override AnalogyToolTip? ToolTip { get; set; } = new AnalogyToolTip("Example tooltip", "some content", "footer/title", Resources.Analogy_image_16x16, Resources.Analogy_image_32x32); @@ -35,7 +33,5 @@ public override Task SaveSettingsAsync() { return Task.CompletedTask; } - - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ExtensionExample.cs b/Analogy.LogViewer.Example/IAnalogy/ExtensionExample.cs index 7552f67..6ea8718 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ExtensionExample.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ExtensionExample.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using System.Windows.Forms; -using Analogy.Interfaces; +using Analogy.Interfaces; using Analogy.Interfaces.DataTypes; using Analogy.Interfaces.Factories; using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Windows.Forms; namespace Analogy.LogViewer.Example.IAnalogy { @@ -15,8 +15,6 @@ public class ExtensionFactoryExample : IAnalogyExtensionsFactory public string Title { get; set; } = "Extension Example"; public IEnumerable Extensions { get; } = new List { new ExtensionInPlaceExample(), new ExtensionUserControlExample() }; } - - public class ExtensionInPlaceExample : IAnalogyExtensionInPlace { public Guid Id { get; set; } = new Guid("8F66A278-CC9C-4643-8045-165572FF17D4"); @@ -51,9 +49,8 @@ public void NewMessages(List messages) { // } - - } + public class ExtensionUserControlExample : IAnalogyExtensionUserControl { public Guid Id { get; set; } = new Guid("34c45425-8acd-4f8e-b901-d234297fe3ec"); @@ -69,15 +66,18 @@ Task IAnalogyExtensionUserControl.InitializeUserControl(Control hostingControl, { return Task.CompletedTask; } - public UserControl CreateUserControl(Guid logWindowsId,ILogger logger) + + public UserControl CreateUserControl(Guid logWindowsId, ILogger logger) { UserControl = new UserControlExtensionExample(); return UserControl; } + public UserControl GetUserControl(Guid logWindowsId) { return UserControl; } + public void NewMessage(IAnalogyLogMessage message, Guid logWindowsId) { (UserControl as UserControlExtensionExample)?.UserClickMessage(message); @@ -87,8 +87,5 @@ public void NewMessages(List messages, Guid logWindowsId) { // } - - } - -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/OfflineExampleDataProvider.cs b/Analogy.LogViewer.Example/IAnalogy/OfflineExampleDataProvider.cs index 5eb05cc..1332ec3 100644 --- a/Analogy.LogViewer.Example/IAnalogy/OfflineExampleDataProvider.cs +++ b/Analogy.LogViewer.Example/IAnalogy/OfflineExampleDataProvider.cs @@ -1,13 +1,13 @@ -using System; +using Analogy.Interfaces; +using Analogy.LogViewer.Example.Properties; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Analogy.Interfaces; -using Analogy.LogViewer.Example.Properties; -using Microsoft.Extensions.Logging; namespace Analogy.LogViewer.Example.IAnalogy { @@ -21,10 +21,10 @@ public sealed class OfflineExampleDataProvider : Template.OfflineDataProvider public override string FileOpenDialogFilters { get; set; } = "None (*.none)|*.none"; public override IEnumerable SupportFormats { get; set; } = new[] { "*.none" }; public override string? InitialFolderFullPath { get; set; } = Environment.CurrentDirectory; - public override IEnumerable<(string originalHeader, string replacementHeader)> GetReplacementHeaders() + public override IEnumerable<(string OriginalHeader, string ReplacementHeader)> GetReplacementHeaders() => Array.Empty<(string, string)>(); - public override (Color backgroundColor, Color foregroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) + public override (Color BackgroundColor, Color ForegroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) => (Color.Empty, Color.Empty); public OfflineExampleDataProvider(string prefix, Guid guid) { @@ -77,7 +77,5 @@ public override bool CanOpenAllFiles(IEnumerable fileNames) { return fileNames.All(CanOpenFile); } - - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/OnlineExampleDataProvider.cs b/Analogy.LogViewer.Example/IAnalogy/OnlineExampleDataProvider.cs index e5b0898..7e96ce9 100644 --- a/Analogy.LogViewer.Example/IAnalogy/OnlineExampleDataProvider.cs +++ b/Analogy.LogViewer.Example/IAnalogy/OnlineExampleDataProvider.cs @@ -1,12 +1,12 @@ -using System; +using Analogy.Interfaces; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Analogy.Interfaces; -using Microsoft.Extensions.Logging; using Timer = System.Timers.Timer; namespace Analogy.LogViewer.Example.IAnalogy @@ -20,20 +20,20 @@ public sealed class OnlineExampleDataProvider : Template.OnlineDataProvider private readonly Timer _simulateOnlineMessages; private long _messageCount; - readonly Random _random = new Random(); - readonly Array _values = Enum.GetValues(typeof(AnalogyLogLevel)); + private readonly Random random = new Random(); + private readonly Array values = Enum.GetValues(typeof(AnalogyLogLevel)); private readonly List _processes = Process.GetProcesses().Select(p => p.ProcessName).ToList(); private readonly string _prefixMessage; - public override IEnumerable<(string originalHeader, string replacementHeader)> GetReplacementHeaders() + public override IEnumerable<(string OriginalHeader, string ReplacementHeader)> GetReplacementHeaders() { yield return ("Category", "Test"); } - public override (Color backgroundColor, Color foregroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) + public override (Color BackgroundColor, Color ForegroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) => logMessage.Level == AnalogyLogLevel.Unknown - ? (Color.FromArgb(_random.Next(256), _random.Next(256), _random.Next(256)), - Color.FromArgb(_random.Next(256), _random.Next(256), _random.Next(256))) + ? (Color.FromArgb(random.Next(256), random.Next(256), random.Next(256)), + Color.FromArgb(random.Next(256), random.Next(256), random.Next(256))) : (Color.Empty, Color.Empty); public OnlineExampleDataProvider(string prefix, Guid guid) { @@ -41,20 +41,19 @@ public OnlineExampleDataProvider(string prefix, Guid guid) Id = guid; OptionalTitle = $"Analogy Example: Real time Data Provider {prefix}"; _simulateOnlineMessages = new Timer(100); - } + public override async Task InitializeDataProvider(ILogger logger) { await base.InitializeDataProvider(logger); _simulateOnlineMessages.Elapsed += (s, e) => { - - AnalogyLogLevel randomLevel = (AnalogyLogLevel)_values.GetValue(_random.Next(_values.Length))!; - string randomProcess = _processes[_random.Next(_processes.Count)]; + AnalogyLogLevel randomLevel = (AnalogyLogLevel)values.GetValue(random.Next(values.Length))!; + string randomProcess = _processes[random.Next(_processes.Count)]; AnalogyLogMessage m = new AnalogyLogMessage { - Text = $"{_prefixMessage}: Generated message #{_messageCount++}" + string.Join(Environment.NewLine, Enumerable.Range(0, _random.Next(1, 5)).Select(i => $" row {i}")), + Text = $"{_prefixMessage}: Generated message #{_messageCount++}" + string.Join(Environment.NewLine, Enumerable.Range(0, random.Next(1, 5)).Select(i => $" row {i}")), Level = randomLevel, Class = AnalogyLogClass.General, Source = "Example", @@ -63,10 +62,9 @@ public override async Task InitializeDataProvider(ILogger logger) MachineName = Environment.MachineName, ThreadId = Thread.CurrentThread.ManagedThreadId, }; - m.AddOrReplaceAdditionalProperty("Random Column", _random.Next(0, 10).ToString()); - m.AddOrReplaceAdditionalProperty("Random Column 2", _random.Next(0, 10).ToString()); + m.AddOrReplaceAdditionalProperty("Random Column", random.Next(0, 10).ToString()); + m.AddOrReplaceAdditionalProperty("Random Column 2", random.Next(0, 10).ToString()); MessageReady(this, new AnalogyLogMessageArgs(m, Environment.MachineName, "Example", Id)); - }; } @@ -88,4 +86,4 @@ public override Task ShutDown() return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/PrimaryFactory.cs b/Analogy.LogViewer.Example/IAnalogy/PrimaryFactory.cs index 3139771..d02cf2e 100644 --- a/Analogy.LogViewer.Example/IAnalogy/PrimaryFactory.cs +++ b/Analogy.LogViewer.Example/IAnalogy/PrimaryFactory.cs @@ -1,8 +1,8 @@ -using System; +using Analogy.Interfaces; +using Analogy.LogViewer.Example.Properties; +using System; using System.Collections.Generic; using System.Drawing; -using Analogy.Interfaces; -using Analogy.LogViewer.Example.Properties; namespace Analogy.LogViewer.Example.IAnalogy { @@ -17,15 +17,15 @@ public class PrimaryFactory : Analogy.LogViewer.Template.PrimaryFactory public override IEnumerable ChangeLog { get; set; } = new List { - new AnalogyChangeLog("Update Analogy.Interface version to 2.8.0",AnalogChangeLogType.None, "Lior Banai",new DateTime(2020, 10, 24), ""), - new AnalogyChangeLog("Update Analogy.Interface version to 2.2.0",AnalogChangeLogType.None, "Lior Banai",new DateTime(2020, 03, 30), ""), - new AnalogyChangeLog("Update Analogy.Interface version to 2.1.7",AnalogChangeLogType.None, "Lior Banai",new DateTime(2019, 09, 14), ""), - new AnalogyChangeLog("Create example implementation",AnalogChangeLogType.None, "Lior Banai",new DateTime(2019, 08, 15), ""), - new AnalogyChangeLog("Add Thread ID",AnalogChangeLogType.None, "Lior Banai",new DateTime(2019, 08, 20), ""), - new AnalogyChangeLog("Add File handler for online data source (aligned with new interface)",AnalogChangeLogType.None, "Lior Banai",new DateTime(2019, 09, 09), ""), - new AnalogyChangeLog("Update new interface and add more than 1 data provider",AnalogChangeLogType.None, "Lior Banai",new DateTime(2019, 12, 01), "") + new AnalogyChangeLog("Update Analogy.Interface version to 2.8.0", AnalogChangeLogType.None, "Lior Banai", new DateTime(2020, 10, 24), ""), + new AnalogyChangeLog("Update Analogy.Interface version to 2.2.0", AnalogChangeLogType.None, "Lior Banai", new DateTime(2020, 03, 30), ""), + new AnalogyChangeLog("Update Analogy.Interface version to 2.1.7", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 09, 14), ""), + new AnalogyChangeLog("Create example implementation", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 08, 15), ""), + new AnalogyChangeLog("Add Thread ID", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 08, 20), ""), + new AnalogyChangeLog("Add File handler for online data source (aligned with new interface)", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 09, 09), ""), + new AnalogyChangeLog("Update new interface and add more than 1 data provider", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 12, 01), ""), }; public override IEnumerable Contributors { get; set; } = new List { "Lior Banai" }; public override string About { get; set; } = "Analogy Example Data Source"; } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/ServerSidePagingProvider.cs b/Analogy.LogViewer.Example/IAnalogy/ServerSidePagingProvider.cs index 56ca5e9..761f591 100644 --- a/Analogy.LogViewer.Example/IAnalogy/ServerSidePagingProvider.cs +++ b/Analogy.LogViewer.Example/IAnalogy/ServerSidePagingProvider.cs @@ -1,11 +1,11 @@ -using System; +using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Analogy.Interfaces; -using Analogy.Interfaces.DataTypes; namespace Analogy.LogViewer.Example.IAnalogy { @@ -13,14 +13,14 @@ public class ServerSidePagingProvider : Template.IAnalogy.AnalogyProviderSidePag { public override Guid Id { get; set; } = new Guid("877808EC-A3DC-4451-986F-6A7569CDE660"); public override string? OptionalTitle { get; set; } = "Example Server Side Paging"; - readonly Array _values = Enum.GetValues(typeof(AnalogyLogLevel)); + private readonly Array _values = Enum.GetValues(typeof(AnalogyLogLevel)); private readonly Random _random = new Random(); private readonly List _processes = Process.GetProcesses().Select(p => p.ProcessName).ToList(); private List messages; public ServerSidePagingProvider() { messages = new List(); - Task.Run(() => + _ = Task.Run(() => { var msg = new List(); @@ -39,20 +39,17 @@ public ServerSidePagingProvider() Module = randomProcess, MachineName = Environment.MachineName, ThreadId = Thread.CurrentThread.ManagedThreadId, - }; msg.Add(m); } messages = msg; }); - } public override Task> FetchMessages(int pageNumber, int pageCount, FilterCriteria filterCriteria, CancellationToken token, ILogMessageCreatedHandler messagesHandler) { - var filters = messages.Where(m => m.Date >= (filterCriteria.StartTime ?? DateTime.MinValue) && m.Date <= (filterCriteria.EndTime ?? DateTime.MaxValue)); @@ -63,6 +60,7 @@ public override Task> FetchMessages(int pageNumb { continue; } + filters = filters.Where(m => m.Text is not null && Contains(m.Text, include, StringComparison.InvariantCultureIgnoreCase)); } @@ -123,6 +121,7 @@ public override Task> FetchMessages(int pageNumb { filters = filters.Where(m => m.Level ==include); } + foreach (var exclude in filterCriteria.ExcludeLevels) { filters = filters.Where(m => m.Level != exclude); @@ -132,7 +131,6 @@ public override Task> FetchMessages(int pageNumb { if (dynamicColumn.FilterType == AnalogyColumnFilterType.Include) { - filters = filters.Where(m => m.AdditionalProperties != null && m.AdditionalProperties.ContainsKey(dynamicColumn.ColumnName) && m.AdditionalProperties[dynamicColumn.ColumnName] @@ -146,7 +144,6 @@ public override Task> FetchMessages(int pageNumb if (m.AdditionalProperties == null) { return true; - } return @@ -155,6 +152,7 @@ public override Task> FetchMessages(int pageNumb }); } } + var result = filters.Skip((pageNumber - 1) * pageCount).Take(pageCount).ToList(); messagesHandler.AppendMessages(result, OptionalTitle ?? "Example "); return Task.FromResult(result.AsEnumerable()); @@ -164,6 +162,5 @@ private static bool Contains(string source, string toCheck, StringComparison com { return string.IsNullOrEmpty(toCheck) || (!string.IsNullOrEmpty(source) && source.IndexOf(toCheck, comp) >= 0); } - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/IAnalogy/UserControlExtensionExample.cs b/Analogy.LogViewer.Example/IAnalogy/UserControlExtensionExample.cs index 3a06e91..ad994c8 100644 --- a/Analogy.LogViewer.Example/IAnalogy/UserControlExtensionExample.cs +++ b/Analogy.LogViewer.Example/IAnalogy/UserControlExtensionExample.cs @@ -12,4 +12,4 @@ public UserControlExtensionExample() public void UserClickMessage(IAnalogyLogMessage msg) => lblMsg.Text = msg.Text; } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Example/OnDemandPlottingContainer.cs b/Analogy.LogViewer.Example/OnDemandPlottingContainer.cs index 5243210..6c2b60e 100644 --- a/Analogy.LogViewer.Example/OnDemandPlottingContainer.cs +++ b/Analogy.LogViewer.Example/OnDemandPlottingContainer.cs @@ -1,12 +1,11 @@ -using Analogy.LogViewer.Example.IAnalogy; +using Analogy.Interfaces; +using Analogy.LogViewer.Example.IAnalogy; using System; -using Analogy.Interfaces; namespace Analogy.LogViewer.Example { public class OnDemandPlottingContainer { - private static readonly Lazy _instance = new Lazy(() => new OnDemandPlottingContainer()); @@ -16,7 +15,6 @@ public class OnDemandPlottingContainer public OnDemandPlottingContainer() { - } public void SetFactory(ExampleOnDemandPlottingFactory analogyFactory) @@ -29,4 +27,4 @@ public void AddOnDemandPlotting(IAnalogyOnDemandPlotting plotGenerator) AnalogyFactory.AddedOnDemandPlottingGenerator(plotGenerator); } } -} +} \ 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