Skip to content

Commit

Permalink
NET8
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Nov 16, 2023
1 parent 58c4a25 commit 349fb4d
Show file tree
Hide file tree
Showing 45 changed files with 222 additions and 234 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net7.0-windows;net6.0-windows</TargetFrameworks>
<Version>2.0.3.1</Version>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net8.0-windows;net7.0-windows;net6.0-windows</TargetFrameworks>
<Version>6.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Analogy.LogViewer.Serilog.Sinks" Version="5.0.3.1" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Analogy.LogViewer.Serilog.Sinks" Version="6.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.Enrichers.CorrelationId" Version="3.0.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public IActionResult Error()
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
}
2 changes: 1 addition & 1 deletion Analogy.LogViewer.Serilog.AspNet/Models/ErrorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ public class ErrorViewModel

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}
}
6 changes: 3 additions & 3 deletions Analogy.LogViewer.Serilog.AspNet/Program.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -25,4 +25,4 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
webBuilder.UseStartup<Startup>();
});
}
}
}
6 changes: 3 additions & 3 deletions Analogy.LogViewer.Serilog.AspNet/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<Startup> logger)
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger)
{
//var log = new LoggerConfiguration()
// .WriteTo.AnalogyLogServerSink("http://localhost:7000").CreateLogger();
Expand Down Expand Up @@ -58,4 +58,4 @@ public async void Configure(IApplicationBuilder app, IWebHostEnvironment env,ILo
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<TargetFrameworks>net8.0-windows;net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<Copyright>Lior Banai © 2022-2023</Copyright>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<Folder Include="IAnalogy\" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Analogy.CommonUtilities" Version="5.0.3" />
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="5.0.3" />
<PackageReference Include="Analogy.LogViewer.Template" Version="5.0.3" />
<PackageReference Include="Microsoft.Build.Tasks.Git" Version="1.1.1">
<PackageReference Include="Analogy.CommonUtilities" Version="6.0.0" />
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="6.0.0.1" />
<PackageReference Include="Analogy.LogViewer.Template" Version="6.0.0" />
<PackageReference Include="Microsoft.Build.Tasks.Git" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -22,7 +23,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="System.Resources.Extensions" Version="7.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="System.Resources.Extensions" Version="8.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Analogy.LogViewer.Serilog.Sinks.MongoDB/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace Analogy.LogViewer.Serilog.Sinks.MongoDB
public class Class1
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net7.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net8.0-windows</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<!--<PackageReference Include="Analogy.LogViewer.Serilog.Sinks" Version="0.1.3" />-->
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions Analogy.LogViewer.Serilog.Sinks.Tests/Enrichers.cs
Original file line number Diff line number Diff line change
@@ -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)
{
Expand All @@ -32,4 +31,4 @@ private static LogEventProperty CreateProperty(ILogEventPropertyFactory property
return propertyFactory.CreateProperty("Process Name", value);
}
}
}
}
15 changes: 6 additions & 9 deletions Analogy.LogViewer.Serilog.Sinks.Tests/Form1.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()
Expand All @@ -34,7 +33,6 @@ public Form1()

private void Form1_Load(object sender, EventArgs e)
{

}

private async void button1_Click(object sender, EventArgs e)
Expand All @@ -51,6 +49,5 @@ private void button2_Click(object sender, EventArgs e)
log = new LoggerConfiguration()
.WriteTo.AnalogyLogServerSink(txtAddress.Text).CreateLogger();
}

}
}
}
6 changes: 3 additions & 3 deletions Analogy.LogViewer.Serilog.Sinks.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

namespace Analogy.LogViewer.Serilog.Sinks.Tests
{
static class Program
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
public static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@

<PropertyGroup>
<TargetFrameworks>net8.0-windows;net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<VersionPrefix>6.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>Lior Banai</Authors>
<Company>Analogy.LogViewer</Company>
<Copyright>Lior Banai © 2020-2023</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Lior Banai © 2020-2024</Copyright>
<PackageProjectUrl>https://github.com/Analogy-LogViewer/Analogy.LogViewer.Serilog</PackageProjectUrl>
<PackageIcon>AnalogySerilog.png</PackageIcon>
<RepositoryUrl>https://github.com/Analogy-LogViewer/Analogy.LogViewer.Serilog</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net471;net472;net7.0-windows</TargetFrameworks>
<TargetFrameworks>net471;net472;net7.0-windows;net8.0-windows</TargetFrameworks>
<IsPackable>false</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="5.0.3" />
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="6.0.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
Expand Down
20 changes: 8 additions & 12 deletions Analogy.LogViewer.Serilog.UnitTests/CompactJsonFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> { "*.Clef", "*.log", "*.gz", "*.zip" };
Expand All @@ -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")]
Expand All @@ -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]
Expand Down Expand Up @@ -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);
Expand All @@ -92,7 +91,6 @@ public async Task CompactJsonFormatSourceContextTest()
Assert.IsNotNull(secondEvent.MethodName);
}


[TestMethod]
public async Task CompactJsonFormatTestColumns()
{
Expand All @@ -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]
Expand All @@ -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\"]");

}


}
}
Loading

0 comments on commit 349fb4d

Please sign in to comment.