Skip to content

PropertyEnricher has not been updated for nullable reference types #1686

@taspeotis

Description

@taspeotis

Hi team,

For your consideration: some methods for manipulating the LogContext worked previously with null values but now the nullable reference types disallow it. This occurs with 2.11.0.

PropertyEnricher.cs had #nullable enable added to it, but value and _value were not changed from object to object?.

The documentation tells us that it is not an exception to pass null for value, only name:

/// <exception cref="ArgumentNullException">When <paramref name="name"/> is <code>null</code></exception>
/// <exception cref="ArgumentException">When <paramref name="name"/> is empty or only contains whitespace</exception>

Ultimately _value is used with propertyFactory.CreateProperty(_name, _value, _destructureObjects); which seems to tolerate null values:

public LogEventProperty CreateProperty(string? name, object? value, bool destructureObjects = false)

Upgrading Serilog causes compile errors were there previously were none.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions