Skip to content

Commit

Permalink
Update to .NET 8 RTM and Serilog 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nblumhardt committed Nov 14, 2023
1 parent 0ea70d3 commit a234c68
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 26 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.100-rc.2.23502.2"
"version": "8.0.100"
}
}
12 changes: 6 additions & 6 deletions sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Expressions" Version="3.3.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="PolySharp" Version="1.13.1" PrivateAssets="all" />
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="PolySharp" Version="1.13.1" PrivateAssets="All" />
<PackageReference Include="Serilog" Version="3.1.0-*" />
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="All" />
<PackageReference Include="Serilog" Version="3.1.1" />
<None Include="..\..\assets\icon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<ItemGroup>
<!-- The versions of all references in this group must match the major and minor components of the package version prefix. -->
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0-*" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0-*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CliWrap" Version="3.6.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NuGet.Frameworks" Version="6.5.0" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Serilog.Expressions" Version="3.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="CliWrap" Version="3.6.4" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NuGet.Frameworks" Version="6.7.0" />
<PackageReference Include="Polly" Version="8.2.0" />
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions test/TestApp-net48/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FodyWeavers.xml
FodyWeavers.xsd
70 changes: 70 additions & 0 deletions test/TestApp-net48/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Serilog;
using Serilog.Debugging;
using Serilog.Settings.Configuration;

if (args.Length == 1 && args[0] == "is-single-file")
{
if (typeof(Program).Assembly.GetManifestResourceNames().Any(e => e.StartsWith("costura.")))
{
Console.WriteLine(true);
return 0;
}
// IL3000: 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app
#pragma warning disable IL3000
Console.WriteLine(string.IsNullOrEmpty(Assembly.GetEntryAssembly()?.Location));
#pragma warning restore
return 0;
}

SelfLog.Enable(Console.Error);

Thread.CurrentThread.Name = "Main thread";
const string outputTemplate = "({ThreadName}) [{Level}] {Message}{NewLine}";

var configurationValues = new Dictionary<string, string?>();
var minimumLevelOnly = args.Contains("--minimum-level-only");
if (minimumLevelOnly)
{
configurationValues["Serilog:MinimumLevel"] = "Verbose";
}
else
{
configurationValues["Serilog:Enrich:0"] = "WithThreadName";
configurationValues["Serilog:WriteTo:0:Name"] = "Console";
configurationValues["Serilog:WriteTo:0:Args:outputTemplate"] = outputTemplate;
}

if (args.Contains("--using-thread")) configurationValues["Serilog:Using:Thread"] = "Serilog.Enrichers.Thread";
if (args.Contains("--using-console")) configurationValues["Serilog:Using:Console"] = "Serilog.Sinks.Console";

var assemblies = new List<Assembly>();
if (args.Contains("--assembly-thread")) assemblies.Add(typeof(ThreadLoggerConfigurationExtensions).Assembly);
if (args.Contains("--assembly-console")) assemblies.Add(typeof(ConsoleLoggerConfigurationExtensions).Assembly);

try
{
var configuration = new ConfigurationBuilder().AddInMemoryCollection(configurationValues).Build();
var options = assemblies.Count > 0 ? new ConfigurationReaderOptions(assemblies.ToArray()) : null;
var loggerConfiguration = new LoggerConfiguration().ReadFrom.Configuration(configuration, options);
if (minimumLevelOnly)
{
loggerConfiguration
.Enrich.WithThreadName()
.WriteTo.Console(outputTemplate: outputTemplate);
}
var logger = loggerConfiguration.CreateLogger();
logger.Information("Expected success");
return 0;
}
catch (InvalidOperationException exception) when (exception.Message.StartsWith("No Serilog:Using configuration section is defined and no Serilog assemblies were found."))
{
Console.WriteLine("Expected exception");
return 0;
}
catch (Exception exception)
{
Console.Error.WriteLine(exception);
return 1;
}
30 changes: 30 additions & 0 deletions test/TestApp-net48/TestApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net48</TargetFramework>
<DebugType>embedded</DebugType>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<GenerateSupportedRuntime>false</GenerateSupportedRuntime>
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles>
<AllowedReferenceRelatedFileExtensions>none</AllowedReferenceRelatedFileExtensions>
<UseCurrentRuntimeIdentifier>true</UseCurrentRuntimeIdentifier>
<SelfContained>true</SelfContained>
</PropertyGroup>

<ItemGroup Condition="$(Configuration) == 'Debug'">
<ProjectReference Include="..\..\src\Serilog.Settings.Configuration\Serilog.Settings.Configuration.csproj" />
</ItemGroup>

<ItemGroup Condition="$(Configuration) == 'Release'">
<PackageReference Include="Serilog.Settings.Configuration" Version="[0.0.0-IntegrationTest.0]" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions test/TestApp-net48/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="packages" />
</config>
<packageSources>
<clear />
<add key="local" value="." />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
4 changes: 2 additions & 2 deletions test/TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

<ItemGroup>
<PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion test/TestDummies/DummyPolicy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Serilog.Core;
using Serilog.Events;
using System.Collections;
using System.Diagnostics.CodeAnalysis;

namespace TestDummies;

Expand All @@ -24,7 +25,7 @@ public class DummyPolicy : IDestructuringPolicy

public decimal Decimal { get; set; }

public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue? result)
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result)
{
result = null;
return false;
Expand Down
5 changes: 3 additions & 2 deletions test/TestDummies/TestDummies.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit a234c68

Please sign in to comment.