Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ScalarValue.Null #1774

Merged
merged 4 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Serilog/Capturing/DepthLimiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ LogEventPropertyValue ILogEventPropertyValueFactory.CreatePropertyValue(object v
if (depth == _maximumDestructuringDepth)
{
SelfLog.WriteLine("Maximum destructuring depth reached.");
return new ScalarValue(null);
return ScalarValue.Null;
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog/Capturing/PropertyValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ LogEventPropertyValue CreatePropertyValue(object? value, bool destructureObjects
LogEventPropertyValue CreatePropertyValue(object? value, Destructuring destructuring, int depth)
{
if (value == null)
return new ScalarValue(null);
return ScalarValue.Null;

if (destructuring == Destructuring.Stringify)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Serilog/Events/ScalarValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ namespace Serilog.Events;
/// </summary>
public class ScalarValue : LogEventPropertyValue
{
/// <summary>
/// Scalar value representing <see langword="null"/>.
/// </summary>
public static readonly ScalarValue Null = new(null);
nblumhardt marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Construct a <see cref="ScalarValue"/> with the specified
/// value.
Expand Down