From 349fb4d973cf6e7acac5b4419149e9b6e974a6d3 Mon Sep 17 00:00:00 2001 From: Lior Banai Date: Thu, 16 Nov 2023 17:52:19 +0200 Subject: [PATCH] NET8 --- .editorconfig | 1 + .../Analogy.LogViewer.Serilog.AspNet.csproj | 14 ++--- .../Controllers/HomeController.cs | 2 +- .../Models/ErrorViewModel.cs | 2 +- Analogy.LogViewer.Serilog.AspNet/Program.cs | 6 +- Analogy.LogViewer.Serilog.AspNet/Startup.cs | 6 +- ...ogy.LogViewer.Serilog.Sinks.MongoDB.csproj | 15 ++--- .../Class1.cs | 2 +- ...alogy.LogViewer.Serilog.Sinks.Tests.csproj | 13 ++-- .../Enrichers.cs | 11 ++-- .../Form1.cs | 15 ++--- .../Program.cs | 6 +- .../Analogy.LogViewer.Serilog.Sinks.csproj | 12 +--- ...Analogy.LogViewer.Serilog.UnitTests.csproj | 7 ++- .../CompactJsonFormatTests.cs | 20 +++--- .../JsonFormatTests.cs | 6 +- .../MessageHandlerForTesting.cs | 4 +- Analogy.LogViewer.Serilog.sln | 2 + .../Analogy.LogViewer.Serilog.csproj | 45 +++----------- Analogy.LogViewer.Serilog/AnalogySink.cs | 7 +-- Analogy.LogViewer.Serilog/ChangeLogList.cs | 5 +- Analogy.LogViewer.Serilog/Constants.cs | 3 +- Analogy.LogViewer.Serilog/DataTypes/Enums.cs | 4 +- .../DataTypes/LogEventReader.cs | 17 +++--- .../DataTypes/MessageFields.cs | 31 +++++----- .../DataTypes/MessageTemplateSyntax.cs | 4 +- .../DataTypes/ParsingResult.cs | 2 +- .../DataTypes/PropertyFactory.cs | 12 ++-- .../DataTypes/RenderableScalarValue.cs | 8 +-- .../DataTypes/Rendering.cs | 2 +- .../DataTypes/TextException.cs | 6 +- .../IAnalogy/DataProvidersFactory.cs | 7 +-- .../IAnalogy/OfflineDataProvider.cs | 7 +-- .../IAnalogy/PrimaryFactory.cs | 4 +- .../IAnalogy/SerilogDownloadInformation.cs | 2 +- .../IAnalogy/UserSettingsFactory.cs | 8 +-- .../Managers/UserSettingsManager.cs | 14 +---- .../Parsers/CommonParser.cs | 12 ++-- .../Parsers/CompactJsonFormatParser.cs | 12 +--- .../Parsers/JsonFileParser.cs | 10 ++- .../Parsers/JsonFormatterParser.cs | 10 +-- Analogy.LogViewer.Serilog/SerilogSettings.cs | 3 +- .../SerilogUCSettings.cs | 7 +-- BannedSymbols.txt | 9 +++ Directory.Build.props | 61 +++++++++++++++++++ 45 files changed, 222 insertions(+), 234 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/Analogy.LogViewer.Serilog.AspNet/Analogy.LogViewer.Serilog.AspNet.csproj b/Analogy.LogViewer.Serilog.AspNet/Analogy.LogViewer.Serilog.AspNet.csproj index 5a8293e..274e32d 100644 --- a/Analogy.LogViewer.Serilog.AspNet/Analogy.LogViewer.Serilog.AspNet.csproj +++ b/Analogy.LogViewer.Serilog.AspNet/Analogy.LogViewer.Serilog.AspNet.csproj @@ -1,20 +1,18 @@ - + - net7.0-windows;net6.0-windows - 2.0.3.1 - enable - latest + net8.0-windows;net7.0-windows;net6.0-windows + 6.0.0 - - + + - + diff --git a/Analogy.LogViewer.Serilog.AspNet/Controllers/HomeController.cs b/Analogy.LogViewer.Serilog.AspNet/Controllers/HomeController.cs index cab3d54..f885919 100644 --- a/Analogy.LogViewer.Serilog.AspNet/Controllers/HomeController.cs +++ b/Analogy.LogViewer.Serilog.AspNet/Controllers/HomeController.cs @@ -34,4 +34,4 @@ public IActionResult Error() return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.AspNet/Models/ErrorViewModel.cs b/Analogy.LogViewer.Serilog.AspNet/Models/ErrorViewModel.cs index b059e6a..1395b40 100644 --- a/Analogy.LogViewer.Serilog.AspNet/Models/ErrorViewModel.cs +++ b/Analogy.LogViewer.Serilog.AspNet/Models/ErrorViewModel.cs @@ -8,4 +8,4 @@ public class ErrorViewModel public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.AspNet/Program.cs b/Analogy.LogViewer.Serilog.AspNet/Program.cs index 91698bb..115152d 100644 --- a/Analogy.LogViewer.Serilog.AspNet/Program.cs +++ b/Analogy.LogViewer.Serilog.AspNet/Program.cs @@ -1,13 +1,13 @@ +using Analogy.LogViewer.Serilog.Sinks; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Serilog; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Analogy.LogViewer.Serilog.Sinks; -using Serilog; namespace Analogy.LogViewer.Serilog.AspNet { @@ -25,4 +25,4 @@ public static IHostBuilder CreateHostBuilder(string[] args) => webBuilder.UseStartup(); }); } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.AspNet/Startup.cs b/Analogy.LogViewer.Serilog.AspNet/Startup.cs index 3d34d0b..14de8e9 100644 --- a/Analogy.LogViewer.Serilog.AspNet/Startup.cs +++ b/Analogy.LogViewer.Serilog.AspNet/Startup.cs @@ -3,11 +3,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace Analogy.LogViewer.Serilog.AspNet { @@ -27,7 +27,7 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public async void Configure(IApplicationBuilder app, IWebHostEnvironment env,ILogger logger) + public async void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) { //var log = new LoggerConfiguration() // .WriteTo.AnalogyLogServerSink("http://localhost:7000").CreateLogger(); @@ -58,4 +58,4 @@ public async void Configure(IApplicationBuilder app, IWebHostEnvironment env,ILo }); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.Sinks.MongoDB/Analogy.LogViewer.Serilog.Sinks.MongoDB.csproj b/Analogy.LogViewer.Serilog.Sinks.MongoDB/Analogy.LogViewer.Serilog.Sinks.MongoDB.csproj index 4bb298b..c8819b4 100644 --- a/Analogy.LogViewer.Serilog.Sinks.MongoDB/Analogy.LogViewer.Serilog.Sinks.MongoDB.csproj +++ b/Analogy.LogViewer.Serilog.Sinks.MongoDB/Analogy.LogViewer.Serilog.Sinks.MongoDB.csproj @@ -1,8 +1,9 @@ - net7.0-windows;net6.0-windows;net48;net471 + net8.0-windows;net7.0-windows;net6.0-windows;net48;net471 Lior Banai © 2022-2023 + false @@ -10,10 +11,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -22,7 +23,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Analogy.LogViewer.Serilog.Sinks.MongoDB/Class1.cs b/Analogy.LogViewer.Serilog.Sinks.MongoDB/Class1.cs index a7c8318..acac52e 100644 --- a/Analogy.LogViewer.Serilog.Sinks.MongoDB/Class1.cs +++ b/Analogy.LogViewer.Serilog.Sinks.MongoDB/Class1.cs @@ -5,4 +5,4 @@ namespace Analogy.LogViewer.Serilog.Sinks.MongoDB public class Class1 { } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.Sinks.Tests/Analogy.LogViewer.Serilog.Sinks.Tests.csproj b/Analogy.LogViewer.Serilog.Sinks.Tests/Analogy.LogViewer.Serilog.Sinks.Tests.csproj index 1435eca..7f94ea4 100644 --- a/Analogy.LogViewer.Serilog.Sinks.Tests/Analogy.LogViewer.Serilog.Sinks.Tests.csproj +++ b/Analogy.LogViewer.Serilog.Sinks.Tests/Analogy.LogViewer.Serilog.Sinks.Tests.csproj @@ -1,20 +1,19 @@ - + WinExe - true - net7.0-windows - true + net8.0-windows + false - + - - + + diff --git a/Analogy.LogViewer.Serilog.Sinks.Tests/Enrichers.cs b/Analogy.LogViewer.Serilog.Sinks.Tests/Enrichers.cs index 7405826..5abd03f 100644 --- a/Analogy.LogViewer.Serilog.Sinks.Tests/Enrichers.cs +++ b/Analogy.LogViewer.Serilog.Sinks.Tests/Enrichers.cs @@ -1,23 +1,22 @@ using Serilog.Core; +using Serilog.Events; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; -using Serilog.Events; -using System.Diagnostics; -using System.Runtime.CompilerServices; namespace Analogy.LogViewer.Serilog.Sinks.Tests { public class ProcessNameEnricher: ILogEventEnricher { - LogEventProperty _cachedProperty; + private LogEventProperty _cachedProperty; public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddPropertyIfAbsent(GetLogEventProperty(propertyFactory)); - } private LogEventProperty GetLogEventProperty(ILogEventPropertyFactory propertyFactory) { @@ -32,4 +31,4 @@ private static LogEventProperty CreateProperty(ILogEventPropertyFactory property return propertyFactory.CreateProperty("Process Name", value); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.Sinks.Tests/Form1.cs b/Analogy.LogViewer.Serilog.Sinks.Tests/Form1.cs index ebd30ee..fd605d8 100644 --- a/Analogy.LogViewer.Serilog.Sinks.Tests/Form1.cs +++ b/Analogy.LogViewer.Serilog.Sinks.Tests/Form1.cs @@ -1,4 +1,7 @@ -using System; +using Serilog; +using Serilog.Core; +using Serilog.Events; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -9,16 +12,12 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using Serilog; -using Serilog.Core; -using Serilog.Events; namespace Analogy.LogViewer.Serilog.Sinks.Tests { public partial class Form1 : Form { - - Logger log = new LoggerConfiguration() + private Logger log = new LoggerConfiguration() .Enrich.FromLogContext() .Enrich.WithMachineName() .Enrich.WithProcessId() @@ -34,7 +33,6 @@ public Form1() private void Form1_Load(object sender, EventArgs e) { - } private async void button1_Click(object sender, EventArgs e) @@ -51,6 +49,5 @@ private void button2_Click(object sender, EventArgs e) log = new LoggerConfiguration() .WriteTo.AnalogyLogServerSink(txtAddress.Text).CreateLogger(); } - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.Sinks.Tests/Program.cs b/Analogy.LogViewer.Serilog.Sinks.Tests/Program.cs index 17b5a13..a5cd5d9 100644 --- a/Analogy.LogViewer.Serilog.Sinks.Tests/Program.cs +++ b/Analogy.LogViewer.Serilog.Sinks.Tests/Program.cs @@ -6,13 +6,13 @@ namespace Analogy.LogViewer.Serilog.Sinks.Tests { - static class Program + public static class Program { /// /// The main entry point for the application. /// [STAThread] - static void Main() + public static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); @@ -20,4 +20,4 @@ static void Main() Application.Run(new Form1()); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.Sinks/Analogy.LogViewer.Serilog.Sinks.csproj b/Analogy.LogViewer.Serilog.Sinks/Analogy.LogViewer.Serilog.Sinks.csproj index 8e56294..c35f44d 100644 --- a/Analogy.LogViewer.Serilog.Sinks/Analogy.LogViewer.Serilog.Sinks.csproj +++ b/Analogy.LogViewer.Serilog.Sinks/Analogy.LogViewer.Serilog.Sinks.csproj @@ -2,24 +2,14 @@ net8.0-windows;net7.0-windows;net6.0-windows;net48;net471 - true - true - true - snupkg - true - true 6.0.0 Lior Banai Analogy.LogViewer - Lior Banai © 2020-2023 - MIT + Lior Banai © 2020-2024 https://github.com/Analogy-LogViewer/Analogy.LogViewer.Serilog AnalogySerilog.png https://github.com/Analogy-LogViewer/Analogy.LogViewer.Serilog - git - enable - latest diff --git a/Analogy.LogViewer.Serilog.UnitTests/Analogy.LogViewer.Serilog.UnitTests.csproj b/Analogy.LogViewer.Serilog.UnitTests/Analogy.LogViewer.Serilog.UnitTests.csproj index 51fdf13..8cd7931 100644 --- a/Analogy.LogViewer.Serilog.UnitTests/Analogy.LogViewer.Serilog.UnitTests.csproj +++ b/Analogy.LogViewer.Serilog.UnitTests/Analogy.LogViewer.Serilog.UnitTests.csproj @@ -1,12 +1,13 @@ - + - net471;net472;net7.0-windows + net471;net472;net7.0-windows;net8.0-windows false + false - + diff --git a/Analogy.LogViewer.Serilog.UnitTests/CompactJsonFormatTests.cs b/Analogy.LogViewer.Serilog.UnitTests/CompactJsonFormatTests.cs index 2b10f2f..00af39c 100644 --- a/Analogy.LogViewer.Serilog.UnitTests/CompactJsonFormatTests.cs +++ b/Analogy.LogViewer.Serilog.UnitTests/CompactJsonFormatTests.cs @@ -16,11 +16,11 @@ public class CompactJsonFormatTests { private string Folder { get; } = Environment.CurrentDirectory; [TestMethod] - [DataRow("CompactJsonFormat.clef",4, "2016-10-12T04:46:58.0554314Z")] - [DataRow("CompactJsonFormatSourceContextTest.clef",2, "2020-06-18T18:03:19.2248275Z")] - [DataRow("CompactJsonFormatTestColumns.clef",4, "2020-06-26T14:21:34.7233612Z")] - [DataRow("CompactJsonFormat.gz",4, "2016-10-12T04:46:58.0554314Z")] - public async Task OfflineProviderParserTimestampTest(string fileName,int numberOfMessages,string datetimeToParse) + [DataRow("CompactJsonFormat.clef", 4, "2016-10-12T04:46:58.0554314Z")] + [DataRow("CompactJsonFormatSourceContextTest.clef", 2, "2020-06-18T18:03:19.2248275Z")] + [DataRow("CompactJsonFormatTestColumns.clef", 4, "2020-06-26T14:21:34.7233612Z")] + [DataRow("CompactJsonFormat.gz", 4, "2016-10-12T04:46:58.0554314Z")] + public async Task OfflineProviderParserTimestampTest(string fileName, int numberOfMessages, string datetimeToParse) { OfflineDataProvider parser = new OfflineDataProvider(); UserSettingsManager.UserSettings.Settings.SupportFormats= new List { "*.Clef", "*.log", "*.gz", "*.zip" }; @@ -33,7 +33,6 @@ public async Task OfflineProviderParserTimestampTest(string fileName,int numberO Assert.IsTrue(messages[0].Date == dto.DateTime); } - [TestMethod] [DataRow("CompactJsonFormat.clef")] [DataRow("CompactJsonFormatSourceContextTest.clef")] @@ -44,7 +43,6 @@ public void CompactJsonFormatTestAutomaticDetection(string fileName) string file = Path.Combine(Folder, "log files", fileName); var type = OfflineDataProvider.TryDetectFormat(file); Assert.IsTrue(type == FileFormat.CompactJsonFormatPerLine); - } [TestMethod] @@ -81,6 +79,7 @@ public async Task CompactJsonFormatSourceContextTest() Assert.IsNotNull(firstEvent.FileName); Assert.IsNotNull(firstEvent.User); Assert.IsNotNull(firstEvent.MethodName); + // The second event should have a source context var secondEvent = messages.ElementAt(1); Assert.AreEqual("Contextual Log", secondEvent.Text); @@ -92,7 +91,6 @@ public async Task CompactJsonFormatSourceContextTest() Assert.IsNotNull(secondEvent.MethodName); } - [TestMethod] public async Task CompactJsonFormatTestColumns() { @@ -102,10 +100,10 @@ public async Task CompactJsonFormatTestColumns() MessageHandlerForTesting forTesting = new MessageHandlerForTesting(); var messages = (await parser.Process(fileName, cts.Token, forTesting)).ToList(); Assert.AreEqual(4, messages.Count()); + // The first event doesn't have a source context Assert.IsTrue(messages[0].MachineName == "Test"); Assert.IsTrue(messages[1].AdditionalProperties["CustomProperty"] == "\"Custom Value\""); - } [TestMethod] @@ -117,11 +115,9 @@ public async Task CompactJsonFormatTestGZFile() MessageHandlerForTesting forTesting = new MessageHandlerForTesting(); var messages = (await parser.Process(fileName, cts.Token, forTesting)).ToList(); Assert.AreEqual(4, messages.Count()); + // The first event doesn't have a source context Assert.IsTrue(messages[2].AdditionalProperties["Tags"] == "[\"test\", \"orange\"]"); - } - - } } \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.UnitTests/JsonFormatTests.cs b/Analogy.LogViewer.Serilog.UnitTests/JsonFormatTests.cs index 492c896..35dcf7d 100644 --- a/Analogy.LogViewer.Serilog.UnitTests/JsonFormatTests.cs +++ b/Analogy.LogViewer.Serilog.UnitTests/JsonFormatTests.cs @@ -26,7 +26,6 @@ public async Task CompactJsonFormatFullFileTest() Assert.IsTrue(messages[0].MachineName == "MY-MACHINE"); Assert.IsTrue(messages[1].Text.StartsWith("An unknown error occurred")); Assert.IsTrue((messages[1].Module == "My process")); - } [TestMethod] @@ -38,6 +37,7 @@ public async Task JsonFilePerLineTest() MessageHandlerForTesting forTesting = new MessageHandlerForTesting(); var messages = (await p.Process(fileName, cts.Token, forTesting)).ToList(); Assert.IsTrue(messages.Count == 2); + //Assert.IsTrue(messages[0].Text == "Hello, { Name: \"nblumhardt\", Tags: [1, 2, 3] }, 0000007b at 06/07/2016 06:44:57","got"+ messages[0].Text); Assert.IsTrue(messages[0].User == "{ Name: \"nblumhardt\", Tags: [1, 2, 3] }"); } @@ -51,6 +51,7 @@ public async Task JsonFilePerFileTest() MessageHandlerForTesting forTesting = new MessageHandlerForTesting(); var messages = (await parser.Process(fileName, cts.Token, forTesting)).ToList(); Assert.IsTrue(messages.Count == 2); + //Assert.IsTrue(messages[0].Text == "Hello, { Name: \"nblumhardt\", Tags: [1, 2, 3] }, 0000007b at 06/07/2016 06:44:57","got"+ messages[0].Text); Assert.IsTrue(messages[0].User == "{ Name: \"nblumhardt\", Tags: [1, 2, 3] }"); } @@ -100,6 +101,5 @@ public async Task EmptyKeyInPropertyTest() Assert.IsTrue(messages.Count == 1); Assert.IsTrue(messages[0].Text == "A dictionary: @{ FirstKey: \"FirstItem\", SecondKey: \"SecondItem\", : \"\", FourthKey: \"FourthItem\" }"); } - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog.UnitTests/MessageHandlerForTesting.cs b/Analogy.LogViewer.Serilog.UnitTests/MessageHandlerForTesting.cs index 77d0244..195d9c3 100644 --- a/Analogy.LogViewer.Serilog.UnitTests/MessageHandlerForTesting.cs +++ b/Analogy.LogViewer.Serilog.UnitTests/MessageHandlerForTesting.cs @@ -4,7 +4,7 @@ namespace Analogy.LogViewer.Serilog.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.Serilog.sln b/Analogy.LogViewer.Serilog.sln index b38a9b0..78cb078 100644 --- a/Analogy.LogViewer.Serilog.sln +++ b/Analogy.LogViewer.Serilog.sln @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore + Directory.Build.props = Directory.Build.props + .github\workflows\dotnet-core-desktop.yml = .github\workflows\dotnet-core-desktop.yml nuget.config = nuget.config EndProjectSection EndProject diff --git a/Analogy.LogViewer.Serilog/Analogy.LogViewer.Serilog.csproj b/Analogy.LogViewer.Serilog/Analogy.LogViewer.Serilog.csproj index 2c9379b..c2074c6 100644 --- a/Analogy.LogViewer.Serilog/Analogy.LogViewer.Serilog.csproj +++ b/Analogy.LogViewer.Serilog/Analogy.LogViewer.Serilog.csproj @@ -2,56 +2,27 @@ 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 Serilog Parser for Compact Formatting - Lior Banai © 2020-2023 - MIT + Lior Banai © 2020-2024 https://github.com/Analogy-LogViewer/Analogy.LogViewer.Serilog https://github.com/Analogy-LogViewer/Analogy.LogViewer.Serilog - git Analogy Serilog Parsers AnalogySerilog.png - - true - 5.0.3.0 + 6.0.0 Analogy.LogViewer - true - enable - latest README.md - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/Analogy.LogViewer.Serilog/AnalogySink.cs b/Analogy.LogViewer.Serilog/AnalogySink.cs index 1f58b7c..a231b4a 100644 --- a/Analogy.LogViewer.Serilog/AnalogySink.cs +++ b/Analogy.LogViewer.Serilog/AnalogySink.cs @@ -10,14 +10,13 @@ namespace Analogy.LogViewer.Serilog { - class AnalogySink : ILogEventSink + public class AnalogySink : ILogEventSink { - readonly ITextFormatter _textFormatter; + private readonly ITextFormatter _textFormatter; public static string output = string.Empty; public AnalogySink(ITextFormatter textFormatter) { _textFormatter = textFormatter ?? throw new ArgumentNullException(nameof(textFormatter)); - } public void Emit(LogEvent logEvent) @@ -35,7 +34,7 @@ public void Emit(LogEvent logEvent) public static class LoggerConfigurationExtensions { - const string DefaultOutputTemplate = "{Message}{NewLine}{Exception}"; + private const string DefaultOutputTemplate = "{Message}{NewLine}{Exception}"; /// /// Write log events to the . diff --git a/Analogy.LogViewer.Serilog/ChangeLogList.cs b/Analogy.LogViewer.Serilog/ChangeLogList.cs index 213efff..7124677 100644 --- a/Analogy.LogViewer.Serilog/ChangeLogList.cs +++ b/Analogy.LogViewer.Serilog/ChangeLogList.cs @@ -9,6 +9,7 @@ public static class ChangeLogList public static IEnumerable GetChangeLog() => new List { + new AnalogyChangeLog("[V6.0.0] - NET8", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2023, 11, 16), "6.0.0"), new AnalogyChangeLog("[V2.6.0] - [UI] Add parsing counter #374", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2022, 04, 04), ""), new AnalogyChangeLog("[V2.5.0] - Add NET6 compilation target #330", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2021, 11, 09), ""), new AnalogyChangeLog("[V2.3.0] - fill the new Analogy Interface fields #231", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2021, 02, 11), ""), @@ -26,7 +27,7 @@ public static IEnumerable GetChangeLog() => new AnalogyChangeLog("Support for reading compressed files. #45", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2020, 07, 22), ""), new AnalogyChangeLog("Duplicated/Extra columns with the dynamic columns feature. #44", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2020, 07, 10), ""), new AnalogyChangeLog("Add dynamic columns per file properties. #43", AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2020, 07, 03), ""), - new AnalogyChangeLog("Initial version", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 12, 14), "") + new AnalogyChangeLog("Initial version", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 12, 14), ""), }; } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/Constants.cs b/Analogy.LogViewer.Serilog/Constants.cs index 99f14d1..4299a64 100644 --- a/Analogy.LogViewer.Serilog/Constants.cs +++ b/Analogy.LogViewer.Serilog/Constants.cs @@ -22,6 +22,5 @@ public static Dictionary GetFieldValues() .Where(f => f.FieldType == typeof(string)) .ToDictionary(f => f.Name, f => (string)f.GetValue(null)); } - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/Enums.cs b/Analogy.LogViewer.Serilog/DataTypes/Enums.cs index d216513..3e37239 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/Enums.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/Enums.cs @@ -12,6 +12,6 @@ public enum FileFormat public enum FileFormatDetection { Automatic, - Manual + Manual, } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/LogEventReader.cs b/Analogy.LogViewer.Serilog/DataTypes/LogEventReader.cs index 6327e05..f19f447 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/LogEventReader.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/LogEventReader.cs @@ -17,11 +17,11 @@ namespace Analogy.LogViewer.Serilog.DataTypes /// public class LogEventReader : IDisposable { - static readonly MessageTemplateParser Parser = new MessageTemplateParser(); - readonly TextReader _text; - readonly JsonSerializer _serializer; + private static readonly MessageTemplateParser Parser = new MessageTemplateParser(); + private readonly TextReader _text; + private readonly JsonSerializer _serializer; private readonly IMessageFields _messageFields; - int _lineNumber; + private int _lineNumber; /// /// Construct a . @@ -89,7 +89,6 @@ public LogEvent ReadFromString(string document, JsonSerializer serializer = null serializer = serializer ?? CreateSerializer(); var jObject = serializer.Deserialize(new JsonTextReader(new StringReader(document))); return ReadFromJObject(jObject, _messageFields); - } /// @@ -109,8 +108,8 @@ public static LogEvent ReadFromString(string row, IMessageFields messageFields, serializer = serializer ?? CreateSerializer(); var jObject = serializer.Deserialize(new JsonTextReader(new StringReader(row))); return ReadFromJObject(jObject, messageFields); - } + /// /// Read a single log event from an already-deserialized JSON object. /// @@ -219,7 +218,7 @@ private static Exception TryPopulateException(string header, Exception exception var ex = new ExternalException(string.Join(" ", header, info["Message"]?.Value(), ""), (info["HResult"].HasValues ? info["HResult"].Value() : -1)) { - Source = info["Source"]?.Value() + Source = info["Source"]?.Value(), }; return ex; } @@ -276,8 +275,8 @@ private static JsonSerializer CreateSerializer() return JsonSerializer.Create(new JsonSerializerSettings { DateParseHandling = DateParseHandling.None, - Culture = CultureInfo.InvariantCulture + Culture = CultureInfo.InvariantCulture, }); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/MessageFields.cs b/Analogy.LogViewer.Serilog/DataTypes/MessageFields.cs index 73f7fdf..5f54932 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/MessageFields.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/MessageFields.cs @@ -29,8 +29,8 @@ public class CompactJsonFormatMessageFields : IMessageFields public string Message { get; } public string[] Required { get; } public string[] All { get; } - string Prefix = "@"; - string EscapedInitialAt = "@@"; + private string Prefix = "@"; + private string EscapedInitialAt = "@@"; public CompactJsonFormatMessageFields() { @@ -45,7 +45,6 @@ public CompactJsonFormatMessageFields() EscapedInitialAt = "@@"; All = new[] { Timestamp, MessageTemplate, Level, Exception, Renderings, EventId, Message }; Required = new[] { Timestamp, MessageTemplate, Level, Exception, Renderings }; - } public string Unescape(string name) { @@ -65,7 +64,6 @@ public bool IsUnrecognized(string name) } } - public class JsonFormatMessageFields : IMessageFields { public string Timestamp { get; } @@ -78,8 +76,8 @@ public class JsonFormatMessageFields : IMessageFields public string[] All { get; } public string[] Required { get; } - string Prefix = "@"; - string EscapedInitialAt = "@@"; + private string Prefix = "@"; + private string EscapedInitialAt = "@@"; public JsonFormatMessageFields() { @@ -92,7 +90,6 @@ public JsonFormatMessageFields() Message = "@m"; All = new[] { Timestamp, MessageTemplate, Level, Exception, Renderings, EventId, Message }; Required = new[] { Timestamp, MessageTemplate, Level, Exception, Renderings }; - } public string Unescape(string name) { @@ -123,8 +120,8 @@ public class ECSFormatMessageFields : IMessageFields public string Message { get; } public string[] All { get; } public string[] Required { get; } - string Prefix = "@"; - string EscapedInitialAt = "@@"; + private string Prefix = "@"; + private string EscapedInitialAt = "@@"; public ECSFormatMessageFields() { Timestamp = "@timestamp"; @@ -134,11 +131,14 @@ public ECSFormatMessageFields() Renderings = "RenderedMessage"; EventId = "@i"; Message = "message"; - All = new[] { Timestamp, MessageTemplate, Level, Exception, Renderings, EventId, Message - }; - Required = new[] { Timestamp, MessageTemplate, Level, Exception, Renderings - }; - + All = new[] + { + Timestamp, MessageTemplate, Level, Exception, Renderings, EventId, Message, + }; + Required = new[] + { + Timestamp, MessageTemplate, Level, Exception, Renderings, + }; } public string Unescape(string name) { @@ -157,5 +157,4 @@ public bool IsUnrecognized(string name) !All.Contains(name); } } -} - +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/MessageTemplateSyntax.cs b/Analogy.LogViewer.Serilog/DataTypes/MessageTemplateSyntax.cs index c078fa9..13079c2 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/MessageTemplateSyntax.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/MessageTemplateSyntax.cs @@ -2,7 +2,7 @@ namespace Analogy.LogViewer.Serilog.DataTypes { - static class MessageTemplateSyntax + internal static class MessageTemplateSyntax { public static string Escape(string text) { @@ -14,4 +14,4 @@ public static string Escape(string text) return text.Replace("{", "{{").Replace("}", "}}"); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/ParsingResult.cs b/Analogy.LogViewer.Serilog/DataTypes/ParsingResult.cs index 99b547d..3f36218 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/ParsingResult.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/ParsingResult.cs @@ -13,4 +13,4 @@ public ParsingResult(LogEvent? evt, string line) this.Line = line; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/PropertyFactory.cs b/Analogy.LogViewer.Serilog/DataTypes/PropertyFactory.cs index ea68df5..da47961 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/PropertyFactory.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/PropertyFactory.cs @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections.Generic; -using System.Linq; using Newtonsoft.Json.Linq; using Serilog.Events; +using System.Collections.Generic; +using System.Linq; namespace Analogy.LogViewer.Serilog.DataTypes { - static class PropertyFactory + internal static class PropertyFactory { - const string TypeTagPropertyName = "$type"; + private const string TypeTagPropertyName = "$type"; public static LogEventProperty CreateProperty(string name, JToken value, List? renderings) { @@ -32,7 +32,7 @@ public static LogEventProperty CreateProperty(string name, JToken value, List? renderings) + private static LogEventPropertyValue CreatePropertyValue(JToken value, List? renderings) { if (value.Type == JTokenType.Null) { @@ -59,4 +59,4 @@ static LogEventPropertyValue CreatePropertyValue(JToken value, List? new ScalarValue(raw); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/DataTypes/RenderableScalarValue.cs b/Analogy.LogViewer.Serilog/DataTypes/RenderableScalarValue.cs index acba99e..de2ef3f 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/RenderableScalarValue.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/RenderableScalarValue.cs @@ -1,13 +1,13 @@ -using System; +using Serilog.Events; +using System; using System.Collections.Generic; using System.IO; -using Serilog.Events; namespace Analogy.LogViewer.Serilog.DataTypes { - class RenderableScalarValue : ScalarValue + internal class RenderableScalarValue : ScalarValue { - readonly Dictionary _renderings = new Dictionary(); + private readonly Dictionary _renderings = new Dictionary(); public RenderableScalarValue(object? value, List renderings) : base(value) diff --git a/Analogy.LogViewer.Serilog/DataTypes/Rendering.cs b/Analogy.LogViewer.Serilog/DataTypes/Rendering.cs index 1652ece..15972c9 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/Rendering.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/Rendering.cs @@ -1,7 +1,7 @@  namespace Analogy.LogViewer.Serilog.DataTypes { - class Rendering + internal class Rendering { public string Name { get; } public string Format { get; } diff --git a/Analogy.LogViewer.Serilog/DataTypes/TextException.cs b/Analogy.LogViewer.Serilog/DataTypes/TextException.cs index 7b853ac..b77f8f8 100644 --- a/Analogy.LogViewer.Serilog/DataTypes/TextException.cs +++ b/Analogy.LogViewer.Serilog/DataTypes/TextException.cs @@ -16,9 +16,9 @@ namespace Analogy.LogViewer.Serilog.DataTypes { - class TextException : Exception + internal class TextException : Exception { - readonly string _text; + private readonly string _text; public TextException(string text) : base("This exception type provides ToString() access to details only.") @@ -31,4 +31,4 @@ public override string ToString() return _text; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/IAnalogy/DataProvidersFactory.cs b/Analogy.LogViewer.Serilog/IAnalogy/DataProvidersFactory.cs index 37a16c8..1e6b1b3 100644 --- a/Analogy.LogViewer.Serilog/IAnalogy/DataProvidersFactory.cs +++ b/Analogy.LogViewer.Serilog/IAnalogy/DataProvidersFactory.cs @@ -1,6 +1,6 @@ -using System; +using Analogy.Interfaces; +using System; using System.Collections.Generic; -using Analogy.Interfaces; namespace Analogy.LogViewer.Serilog.IAnalogy { @@ -11,6 +11,5 @@ public class DataProvidersFactory : Analogy.LogViewer.Template.DataProvidersFact public override IEnumerable DataProviders { get; set; } = new List { new OfflineDataProvider() }; - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/IAnalogy/OfflineDataProvider.cs b/Analogy.LogViewer.Serilog/IAnalogy/OfflineDataProvider.cs index ab926a5..6a715d9 100644 --- a/Analogy.LogViewer.Serilog/IAnalogy/OfflineDataProvider.cs +++ b/Analogy.LogViewer.Serilog/IAnalogy/OfflineDataProvider.cs @@ -38,10 +38,10 @@ public class OfflineDataProvider : Analogy.LogViewer.Template.OfflineDataProvide private JsonFileParser JsonFileParser { get; } public override bool UseCustomColors { get; set; } - 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 OfflineDataProvider() { @@ -50,7 +50,6 @@ public OfflineDataProvider() JsonPerLineParser = new JsonFormatterParser(new JsonFormatMessageFields()); JsonFileParser = new JsonFileParser(new JsonFormatMessageFields()); - } public override Task InitializeDataProvider(ILogger logger) { @@ -216,4 +215,4 @@ private static string SafeReadAllLines(string path) } } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/IAnalogy/PrimaryFactory.cs b/Analogy.LogViewer.Serilog/IAnalogy/PrimaryFactory.cs index e9b7447..19d884c 100644 --- a/Analogy.LogViewer.Serilog/IAnalogy/PrimaryFactory.cs +++ b/Analogy.LogViewer.Serilog/IAnalogy/PrimaryFactory.cs @@ -1,9 +1,9 @@ using Analogy.Interfaces; using Analogy.Interfaces.Factories; +using Analogy.LogViewer.Serilog.Properties; using System; using System.Collections.Generic; using System.Drawing; -using Analogy.LogViewer.Serilog.Properties; namespace Analogy.LogViewer.Serilog.IAnalogy { @@ -17,7 +17,5 @@ public class PrimaryFactory : Analogy.LogViewer.Template.PrimaryFactory public override string About { get; set; } = "Serilog Parser for Analogy Log Viewer"; public override Image SmallImage { get; set; } = Resources.AnalogySerilog16x16; public override Image LargeImage { get; set; } = Resources.AnalogySerilog32x32; - - } } \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/IAnalogy/SerilogDownloadInformation.cs b/Analogy.LogViewer.Serilog/IAnalogy/SerilogDownloadInformation.cs index 22dca25..c42d7e6 100644 --- a/Analogy.LogViewer.Serilog/IAnalogy/SerilogDownloadInformation.cs +++ b/Analogy.LogViewer.Serilog/IAnalogy/SerilogDownloadInformation.cs @@ -33,4 +33,4 @@ public override string InstalledVersionNumber } } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/IAnalogy/UserSettingsFactory.cs b/Analogy.LogViewer.Serilog/IAnalogy/UserSettingsFactory.cs index bf991d3..9de8dce 100644 --- a/Analogy.LogViewer.Serilog/IAnalogy/UserSettingsFactory.cs +++ b/Analogy.LogViewer.Serilog/IAnalogy/UserSettingsFactory.cs @@ -1,10 +1,10 @@ -using Analogy.LogViewer.Serilog.Properties; +using Analogy.Interfaces; +using Analogy.LogViewer.Serilog.Properties; +using Microsoft.Extensions.Logging; using System; using System.Drawing; using System.Threading.Tasks; using System.Windows.Forms; -using Analogy.Interfaces; -using Microsoft.Extensions.Logging; namespace Analogy.LogViewer.Serilog.IAnalogy { @@ -28,4 +28,4 @@ public override Task SaveSettingsAsync() return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/Managers/UserSettingsManager.cs b/Analogy.LogViewer.Serilog/Managers/UserSettingsManager.cs index 3897f9c..cb06bbf 100644 --- a/Analogy.LogViewer.Serilog/Managers/UserSettingsManager.cs +++ b/Analogy.LogViewer.Serilog/Managers/UserSettingsManager.cs @@ -8,7 +8,6 @@ namespace Analogy.LogViewer.Serilog.Managers { public class UserSettingsManager { - private static readonly Lazy _instance = new Lazy(() => new UserSettingsManager()); public static UserSettingsManager UserSettings { get; set; } = _instance.Value; @@ -19,14 +18,12 @@ public class UserSettingsManager public UserSettingsManager() { - //check if local file exist: var loaded = LoadFileSettings(LocalSettingFileName, true); if (!loaded) { LoadFileSettings(SerilogPerUserFileSetting, false); } - } private bool LoadFileSettings(string localSettingFileName, bool optional) @@ -37,14 +34,13 @@ private bool LoadFileSettings(string localSettingFileName, bool optional) { var settings = new JsonSerializerSettings { - ObjectCreationHandling = ObjectCreationHandling.Replace + ObjectCreationHandling = ObjectCreationHandling.Replace, }; string data = File.ReadAllText(localSettingFileName); Settings = JsonConvert.DeserializeObject(data, settings); if (string.IsNullOrEmpty(Settings.FileOpenDialogFilters)) { Settings.FileOpenDialogFilters = "All Supported formats (*.Clef;*.log;*.gz)|*.clef;*.log;*.gz;*.zip|Clef format (*.clef)|*.clef|Plain log text file (*.log)|*.log|GZIP file (*.gz)|*.gz|ZIP file (*.zip)|*.zip"; - } return true; } @@ -55,7 +51,6 @@ private bool LoadFileSettings(string localSettingFileName, bool optional) if (string.IsNullOrEmpty(Settings.FileOpenDialogFilters)) { Settings.FileOpenDialogFilters = "All Supported formats (*.Clef;*.log;*.gz)|*.clef;*.log;*.gz;*.zip|Clef format (*.clef)|*.clef|Plain log text file (*.log)|*.log|GZIP file (*.gz)|*.gz|ZIP file (*.zip)|*.zip"; - } return true; } @@ -68,7 +63,6 @@ private bool LoadFileSettings(string localSettingFileName, bool optional) if (string.IsNullOrEmpty(Settings.FileOpenDialogFilters)) { Settings.FileOpenDialogFilters = "All Supported formats (*.Clef;*.log;*.gz)|*.clef;*.log;*.gz;*.zip|Clef format (*.clef)|*.clef|Plain log text file (*.log)|*.log|GZIP file (*.gz)|*.gz|ZIP file (*.zip)|*.zip"; - } return false; } @@ -83,7 +77,6 @@ public void Save() { if (Settings.UseApplicationFolderForSettings) { - File.WriteAllText(LocalSettingFileName, JsonConvert.SerializeObject(Settings)); } else @@ -100,15 +93,12 @@ public void Save() } } File.WriteAllText(SerilogPerUserFileSetting, JsonConvert.SerializeObject(Settings)); - } } catch (Exception e) { LogManager.Instance.LogError(e, "Error saving settings: " + e.Message); } - - } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/Parsers/CommonParser.cs b/Analogy.LogViewer.Serilog/Parsers/CommonParser.cs index 75e2603..65c678a 100644 --- a/Analogy.LogViewer.Serilog/Parsers/CommonParser.cs +++ b/Analogy.LogViewer.Serilog/Parsers/CommonParser.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; -using System.Linq; -using Analogy.Interfaces; +using Analogy.Interfaces; using Analogy.LogViewer.Serilog.Managers; using Analogy.LogViewer.Template.Managers; using Microsoft.Extensions.Logging; using Serilog.Events; +using System.Collections.Generic; +using System.Linq; namespace Analogy.LogViewer.Serilog { @@ -103,14 +103,14 @@ public static AnalogyLogMessage ParseLogEventProperties(LogEvent evt) } if (evt.Properties.TryGetValue(Constants.EnvironmentUserName, out var environmentUserName)) { - if (environmentUserName is ScalarValue {Value: string environmentUserNameString}) + if (environmentUserName is ScalarValue { Value: string environmentUserNameString}) { m.User = environmentUserNameString; } } if (evt.Properties.TryGetValue(Constants.User, out var environmentUser)) { - if (environmentUser is ScalarValue {Value: string environmentUserString} scalarValue) + if (environmentUser is ScalarValue { Value: string environmentUserString} scalarValue) { m.User = environmentUserString; } @@ -139,4 +139,4 @@ public static AnalogyLogMessage ParseLogEventProperties(LogEvent evt) return m; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/Parsers/CompactJsonFormatParser.cs b/Analogy.LogViewer.Serilog/Parsers/CompactJsonFormatParser.cs index 4fd002e..d8cccd1 100644 --- a/Analogy.LogViewer.Serilog/Parsers/CompactJsonFormatParser.cs +++ b/Analogy.LogViewer.Serilog/Parsers/CompactJsonFormatParser.cs @@ -1,4 +1,5 @@ using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; using Analogy.LogViewer.Serilog.DataTypes; using Serilog; using System; @@ -8,7 +9,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Analogy.Interfaces.DataTypes; namespace Analogy.LogViewer.Serilog { @@ -50,8 +50,7 @@ public async Task> Process(string fileName, Canc m.RawTextType = AnalogyRowTextType.JSON; parsedMessages.Add(m); count++; - messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Incremental, 1,count, count)); - + messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Incremental, 1, count, count)); } messagesHandler.AppendMessages(parsedMessages, fileName); @@ -73,7 +72,6 @@ public async Task> Process(string fileName, Canc parsedMessages.Add(m); count++; messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Incremental, 1, count, count)); - } messagesHandler.AppendMessages(parsedMessages, fileName); @@ -81,7 +79,6 @@ public async Task> Process(string fileName, Canc } } } - } catch (Exception e) { @@ -93,11 +90,8 @@ public async Task> Process(string fileName, Canc messagesHandler.AppendMessages(parsedMessages, fileName); return parsedMessages; } - - }); return messages; } - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/Parsers/JsonFileParser.cs b/Analogy.LogViewer.Serilog/Parsers/JsonFileParser.cs index c9f0cec..ca01ee8 100644 --- a/Analogy.LogViewer.Serilog/Parsers/JsonFileParser.cs +++ b/Analogy.LogViewer.Serilog/Parsers/JsonFileParser.cs @@ -1,4 +1,5 @@ using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; using Analogy.LogViewer.Serilog.DataTypes; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -11,7 +12,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Analogy.Interfaces.DataTypes; namespace Analogy.LogViewer.Serilog { @@ -52,7 +52,6 @@ public async Task> Process(string fileName, Canc using (var streamReader = new StreamReader(gzStream, encoding: Encoding.UTF8)) { jsonData = streamReader.ReadToEnd(); - } } } @@ -64,7 +63,6 @@ public async Task> Process(string fileName, Canc } } - var data = JsonConvert.DeserializeObject(jsonData, JsonSerializerSettings); if (data is JObject jo) { @@ -74,7 +72,7 @@ public async Task> Process(string fileName, Canc m.RawText = jo.ToString(Formatting.None); m.RawTextType = AnalogyRowTextType.JSON; parsedMessages.Add(m); - messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1, 1,1)); + messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1, 1, 1)); } else if (data is JArray arr) { @@ -89,7 +87,7 @@ public async Task> Process(string fileName, Canc m.RawText = j.ToString(Formatting.None); m.RawTextType = AnalogyRowTextType.JSON; parsedMessages.Add(m); - messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1,i, arr.Count)); + messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1, i, arr.Count)); } } } @@ -114,4 +112,4 @@ public async Task> Process(string fileName, Canc return messages; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/Parsers/JsonFormatterParser.cs b/Analogy.LogViewer.Serilog/Parsers/JsonFormatterParser.cs index 3d6019c..7d3d8c3 100644 --- a/Analogy.LogViewer.Serilog/Parsers/JsonFormatterParser.cs +++ b/Analogy.LogViewer.Serilog/Parsers/JsonFormatterParser.cs @@ -1,4 +1,5 @@ using Analogy.Interfaces; +using Analogy.Interfaces.DataTypes; using Analogy.LogViewer.Serilog.DataTypes; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -10,7 +11,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Analogy.Interfaces.DataTypes; namespace Analogy.LogViewer.Serilog { @@ -28,7 +28,6 @@ public JsonFormatterParser(IMessageFields messageFields) DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Utc, }; - } public async Task> Process(string fileName, CancellationToken token, ILogMessageCreatedHandler messagesHandler) @@ -45,7 +44,6 @@ public async Task> Process(string fileName, Canc using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { - if (fileName.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase)) { using (var gzStream = new GZipStream(fileStream, CompressionMode.Decompress)) @@ -56,7 +54,6 @@ public async Task> Process(string fileName, Canc long count = 0; while ((json = await streamReader.ReadLineAsync()) != null) { - var data = JsonConvert.DeserializeObject(json, JsonSerializerSettings); var jo = data as JObject; var evt = LogEventReader.ReadFromJObject(jo, messageFields); @@ -67,15 +64,12 @@ public async Task> Process(string fileName, Canc m.RawTextType = AnalogyRowTextType.JSON; parsedMessages.Add(m); messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Incremental, 1, count, count)); - } } - } } } - using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { string json; @@ -93,11 +87,9 @@ public async Task> Process(string fileName, Canc parsedMessages.Add(m); count++; messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Incremental, 1, count, count)); - } } } - } messagesHandler.AppendMessages(parsedMessages, fileName); diff --git a/Analogy.LogViewer.Serilog/SerilogSettings.cs b/Analogy.LogViewer.Serilog/SerilogSettings.cs index 4fbe9cd..25a658a 100644 --- a/Analogy.LogViewer.Serilog/SerilogSettings.cs +++ b/Analogy.LogViewer.Serilog/SerilogSettings.cs @@ -3,7 +3,6 @@ namespace Analogy.LogViewer.Serilog { - public class SerilogSettings { public bool UseApplicationFolderForSettings { get; set; } @@ -15,4 +14,4 @@ public class SerilogSettings public FileFormatDetection FileFormatDetection { get; set; } = FileFormatDetection.Automatic; public List IgnoredAttributes { get; set; } = new() { "N" }; } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Serilog/SerilogUCSettings.cs b/Analogy.LogViewer.Serilog/SerilogUCSettings.cs index 553006c..2d0f9e4 100644 --- a/Analogy.LogViewer.Serilog/SerilogUCSettings.cs +++ b/Analogy.LogViewer.Serilog/SerilogUCSettings.cs @@ -80,14 +80,12 @@ private void btnExportSettings_Click(object sender, EventArgs e) File.WriteAllText(saveFileDialog.FileName, JsonConvert.SerializeObject(Settings)); MessageBox.Show("File Saved", @"Export settings", MessageBoxButtons.OK, MessageBoxIcon.Information); - } catch (Exception ex) { MessageBox.Show("Error Export: " + ex.Message, @"Error Saving file", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } } @@ -106,7 +104,6 @@ private void btnImport_Click(object sender, EventArgs e) LoadSettings(settings); MessageBox.Show("File Imported. Save settings if desired", @"Import settings", MessageBoxButtons.OK, MessageBoxIcon.Information); - } catch (Exception ex) { @@ -166,7 +163,7 @@ private void btnTestFilter_Click(object sender, EventArgs e) { Filter = txtbOpenFileFilters.Text, Title = @"Test Open Files", - Multiselect = true + Multiselect = true, }; openFileDialog1.ShowDialog(this); } @@ -194,4 +191,4 @@ private void btnDeleteIgnoreColumn_Click(object sender, EventArgs e) } } } -} +} \ 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