diff --git a/src/Destructurama.Attributed.Tests/Approval/ApiApprovalTests.cs b/src/Destructurama.Attributed.Tests/Approval/ApiApprovalTests.cs index 1ece19e..f787b7b 100644 --- a/src/Destructurama.Attributed.Tests/Approval/ApiApprovalTests.cs +++ b/src/Destructurama.Attributed.Tests/Approval/ApiApprovalTests.cs @@ -24,7 +24,7 @@ public class ApiApprovalTests { /// Check for changes to the public APIs. /// The type used as a marker for the assembly whose public API change you want to check. - [TestCase(typeof(LoggerConfigurationAppSettingsExtensions))] + [TestCase(typeof(LoggerConfigurationAttributedExtensions))] public void PublicApi_Should_Not_Change_Unintentionally(Type type) { string publicApi = type.Assembly.GeneratePublicApi(new() diff --git a/src/Destructurama.Attributed.Tests/Approval/Destructurama.Attributed.approved.txt b/src/Destructurama.Attributed.Tests/Approval/Destructurama.Attributed.approved.txt index d3bb2d5..e112361 100644 --- a/src/Destructurama.Attributed.Tests/Approval/Destructurama.Attributed.approved.txt +++ b/src/Destructurama.Attributed.Tests/Approval/Destructurama.Attributed.approved.txt @@ -67,7 +67,7 @@ namespace Destructurama.Attributed } namespace Destructurama { - public static class LoggerConfigurationAppSettingsExtensions + public static class LoggerConfigurationAttributedExtensions { public static Serilog.LoggerConfiguration UsingAttributes(this Serilog.Configuration.LoggerDestructuringConfiguration configuration) { } public static Serilog.LoggerConfiguration UsingAttributes(this Serilog.Configuration.LoggerDestructuringConfiguration configuration, System.Action configure) { } diff --git a/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs b/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs index 6719d29..9df2639 100644 --- a/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs @@ -40,8 +40,11 @@ public LogAsScalarAttribute(bool isMutable = false) } /// - public LogEventPropertyValue CreateLogEventPropertyValue(object? value, ILogEventPropertyValueFactory propertyValueFactory) => - new ScalarValue(_isMutable ? value?.ToString() : value); + public LogEventPropertyValue CreateLogEventPropertyValue(object? value, ILogEventPropertyValueFactory propertyValueFactory) + { + var v = _isMutable ? value?.ToString() : value; + return v == null ? ScalarValue.Null : new ScalarValue(v); + } /// public bool TryCreateLogEventProperty(string name, object? value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventProperty property) diff --git a/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs b/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs index c2b90f0..4f61694 100644 --- a/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs @@ -119,7 +119,7 @@ private LogEventPropertyValue CreateValue(object? value) { IEnumerable strings => new SequenceValue(strings.Select(s => new ScalarValue(FormatMaskedValue(s)))), string s => new ScalarValue(FormatMaskedValue(s)), - _ => new ScalarValue(null) + _ => ScalarValue.Null }; } } diff --git a/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs b/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs index f1b91be..30c4e18 100644 --- a/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs @@ -54,7 +54,7 @@ public bool TryCreateLogEventProperty(string name, object? value, ILogEventPrope { if (value == null) { - property = new(name, new ScalarValue(value)); + property = new(name, ScalarValue.Null); return true; } diff --git a/src/Destructurama.Attributed/Destructurama.Attributed.csproj b/src/Destructurama.Attributed/Destructurama.Attributed.csproj index a3ded2d..d7ca12d 100644 --- a/src/Destructurama.Attributed/Destructurama.Attributed.csproj +++ b/src/Destructurama.Attributed/Destructurama.Attributed.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs b/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs index b3f9a4b..6c03a3b 100644 --- a/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs +++ b/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs @@ -22,7 +22,7 @@ namespace Destructurama; /// /// Adds the Destructure.UsingAttributes() extension to . /// -public static class LoggerConfigurationAppSettingsExtensions +public static class LoggerConfigurationAttributedExtensions { /// /// Adds a custom to enable manipulation of how objects