Skip to content

Commit

Permalink
fix: Serilog not handling null strings (#925)
Browse files Browse the repository at this point in the history
* fix: Serilog not handling null strings

housekeeping: Update all targets to net462, net461 no longer supported

* Fix message
  • Loading branch information
glennawatson authored Jun 25, 2022
1 parent 476e73c commit 172b6f3
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.ApplicationInsights</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Autofac/Splat.Autofac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<Description>Autofac adapter for Splat</Description>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Drawing/Splat.Drawing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>MonoAndroid90;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;Xamarin.WatchOS10;tizen40;netstandard2.0;net6.0;net6.0-android;net6.0-ios;net6.0-tvos;net6.0-macos;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461;net472;uap10.0.16299;net6.0-windows</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net472;uap10.0.16299;net6.0-windows</TargetFrameworks>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
<Description>A library to make things cross-platform that should be</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.DryIoc/Splat.DryIoc.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<NoWarn>$(NoWarn);CA1801</NoWarn>
<Description>DryIoc adapter for Splat</Description>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Exceptionless/Splat.Exceptionless.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.Exceptionless</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Log4Net/Splat.Log4Net.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.Log4Net</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@ public LogLevel Level
}

/// <inheritdoc />
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1848:Use the LoggerMessage delegates", Justification = "Deliberate Usage")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "Deliberate Usage")]
public void Write(string message, LogLevel logLevel)
{
_inner.Log(MsLoggingHelpers.Splat2MsLogDictionary[logLevel], message);
}

/// <inheritdoc />
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1848:Use the LoggerMessage delegates", Justification = "Deliberate Usage")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "Deliberate Usage")]
public void Write(Exception exception, string message, LogLevel logLevel)
{
_inner.Log(MsLoggingHelpers.Splat2MsLogDictionary[logLevel], exception, message);
}

/// <inheritdoc />
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1848:Use the LoggerMessage delegates", Justification = "Deliberate Usage")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "Deliberate Usage")]
public void Write(string message, Type type, LogLevel logLevel)
{
if (type is null)
Expand All @@ -74,6 +80,8 @@ public void Write(string message, Type type, LogLevel logLevel)
}

/// <inheritdoc />
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1848:Use the LoggerMessage delegates", Justification = "Deliberate Usage")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2254:Template should be a static expression", Justification = "Deliberate Usage")]
public void Write(Exception exception, string message, Type type, LogLevel logLevel)
{
if (type is null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.Microsoft.Extensions.Logging</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.NLog/Splat.NLog.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.NLog</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Ninject/Splat.Ninject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<Description>Autofac adapter for Splat</Description>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Prism.Forms/Splat.Prism.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<Description>Prism adapter for Splat including Xamarin Forms adapters.</Description>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Prism/Splat.Prism.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<Description>Prism adapter for Splat</Description>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Raygun/RaygunFeatureUsageTrackingSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal RaygunFeatureUsageTrackingSession(

// keep an eye on
// https://raygun.com/forums/thread/92182
#if NET461
#if NET462
var messageBuilder = RaygunMessageBuilder.New
#else
var messageBuilder = RaygunMessageBuilder.New(raygunSettings)
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Raygun/Splat.Raygun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.Raygun</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand Down
50 changes: 25 additions & 25 deletions src/Splat.Serilog/SerilogFullLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public LogLevel Level
/// <inheritdoc />
public void Debug<T>(T value)
{
_logger.Debug(value?.ToString());
_logger.Debug(value?.ToString() ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -84,13 +84,13 @@ public void Debug(IFormatProvider formatProvider, [Localizable(false)] string me
/// <inheritdoc />
public void Debug([Localizable(false)] string? message)
{
_logger.Debug(message);
_logger.Debug(message ?? string.Empty);
}

/// <inheritdoc />
public void Debug<T>([Localizable(false)] string? message)
{
_logger.ForContext<T>().Debug(message);
_logger.ForContext<T>().Debug(message ?? string.Empty);
}

/// <inheritdoc />
Expand Down Expand Up @@ -186,19 +186,19 @@ public void Debug<TArgument1, TArgument2, TArgument3, TArgument4, TArgument5, TA
/// <inheritdoc />
public void DebugException([Localizable(false)] string? message, Exception exception)
{
_logger.Debug(exception, message);
_logger.Debug(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
public void Debug(Exception exception, [Localizable(false)] string? message)
{
_logger.Debug(exception, message);
_logger.Debug(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
public void Error<T>(T value)
{
_logger.Error(value?.ToString());
_logger.Error(value?.ToString() ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -210,7 +210,7 @@ public void Error<T>(IFormatProvider formatProvider, T value)
/// <inheritdoc />
public void Error(Exception exception, string? message)
{
_logger.Error(exception, message);
_logger.Error(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -222,13 +222,13 @@ public void Error(IFormatProvider formatProvider, [Localizable(false)] string me
/// <inheritdoc />
public void Error([Localizable(false)] string? message)
{
_logger.Error(message);
_logger.Error(message ?? string.Empty);
}

/// <inheritdoc />
public void Error<T>([Localizable(false)] string? message)
{
_logger.ForContext<T>().Error(message);
_logger.ForContext<T>().Error(message ?? string.Empty);
}

/// <inheritdoc />
Expand Down Expand Up @@ -324,13 +324,13 @@ public void Error<TArgument1, TArgument2, TArgument3, TArgument4, TArgument5, TA
/// <inheritdoc />
public void ErrorException([Localizable(false)] string? message, Exception exception)
{
_logger.Error(exception, message);
_logger.Error(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
public void Fatal<T>(T value)
{
_logger.Fatal(value?.ToString());
_logger.Fatal(value?.ToString() ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -342,7 +342,7 @@ public void Fatal<T>(IFormatProvider formatProvider, T value)
/// <inheritdoc />
public void Fatal(Exception exception, string? message)
{
_logger.Fatal(exception, message);
_logger.Fatal(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -354,13 +354,13 @@ public void Fatal(IFormatProvider formatProvider, [Localizable(false)] string me
/// <inheritdoc />
public void Fatal([Localizable(false)] string? message)
{
_logger.Fatal(message);
_logger.Fatal(message ?? string.Empty);
}

/// <inheritdoc />
public void Fatal<T>([Localizable(false)] string? message)
{
_logger.ForContext<T>().Fatal(message);
_logger.ForContext<T>().Fatal(message ?? string.Empty);
}

/// <inheritdoc />
Expand Down Expand Up @@ -456,13 +456,13 @@ public void Fatal<TArgument1, TArgument2, TArgument3, TArgument4, TArgument5, TA
/// <inheritdoc />
public void FatalException([Localizable(false)] string? message, Exception exception)
{
_logger.Fatal(exception, message);
_logger.Fatal(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
public void Info<T>(T value)
{
_logger.Information(value?.ToString());
_logger.Information(value?.ToString() ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -474,7 +474,7 @@ public void Info<T>(IFormatProvider formatProvider, T value)
/// <inheritdoc />
public void Info(Exception exception, string? message)
{
_logger.Information(exception, message);
_logger.Information(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -486,13 +486,13 @@ public void Info(IFormatProvider formatProvider, [Localizable(false)] string mes
/// <inheritdoc />
public void Info([Localizable(false)] string? message)
{
_logger.Information(message);
_logger.Information(message ?? string.Empty);
}

/// <inheritdoc />
public void Info<T>([Localizable(false)] string? message)
{
_logger.ForContext<T>().Information(message);
_logger.ForContext<T>().Information(message ?? string.Empty);
}

/// <inheritdoc />
Expand Down Expand Up @@ -588,13 +588,13 @@ public void Info<TArgument1, TArgument2, TArgument3, TArgument4, TArgument5, TAr
/// <inheritdoc />
public void InfoException([Localizable(false)] string? message, Exception exception)
{
_logger.Information(exception, message);
_logger.Information(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
public void Warn<T>(T value)
{
_logger.Warning(value?.ToString());
_logger.Warning(value?.ToString() ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -606,7 +606,7 @@ public void Warn<T>(IFormatProvider formatProvider, T value)
/// <inheritdoc />
public void Warn(Exception exception, string? message)
{
_logger.Warning(exception, message);
_logger.Warning(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
Expand All @@ -618,13 +618,13 @@ public void Warn(IFormatProvider formatProvider, [Localizable(false)] string mes
/// <inheritdoc />
public void Warn([Localizable(false)] string? message)
{
_logger.Warning(message);
_logger.Warning(message ?? string.Empty);
}

/// <inheritdoc />
public void Warn<T>([Localizable(false)] string? message)
{
_logger.ForContext<T>().Warning(message);
_logger.ForContext<T>().Warning(message ?? string.Empty);
}

/// <inheritdoc />
Expand Down Expand Up @@ -720,7 +720,7 @@ public void Warn<TArgument1, TArgument2, TArgument3, TArgument4, TArgument5, TAr
/// <inheritdoc />
public void WarnException([Localizable(false)] string? message, Exception exception)
{
_logger.Warning(exception, message);
_logger.Warning(exception, message ?? exception?.Message ?? string.Empty);
}

/// <inheritdoc />
Expand Down
4 changes: 2 additions & 2 deletions src/Splat.Serilog/Splat.Serilog.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyName>Splat.Serilog</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand All @@ -11,7 +11,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.SimpleInjector/Splat.SimpleInjector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
<Description>SimpleInjector adapter for Splat</Description>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down

0 comments on commit 172b6f3

Please sign in to comment.