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

Finish nullable. now enabled globally #1729

Merged
merged 8 commits into from Aug 25, 2022
Merged

Finish nullable. now enabled globally #1729

merged 8 commits into from Aug 25, 2022

Conversation

SimonCropp
Copy link
Contributor

No description provided.

Copy link
Member

@nblumhardt nblumhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Couple of minor queries :-)

src/Serilog/Core/Logger.cs Outdated Show resolved Hide resolved
@@ -67,7 +68,7 @@ internal LogEventProperty(EventProperty property)
/// </summary>
/// <param name="name">The name to check.</param>
/// <returns>True if the name is valid; otherwise, false.</returns>
public static bool IsValidName(string name) => !string.IsNullOrWhiteSpace(name);
public static bool IsValidName([NotNullWhen(true)] string? name) => !string.IsNullOrWhiteSpace(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the attribute makes sense here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this we get build errors, since the compiler cant derive the nullability

Logger.cs(1369, 65): [CS8604] Possible null reference argument for parameter 'name' in 'LogEventProperty MessageTemplateProcessor.CreateProperty(string name, object? value, bool destructureObjects = false)'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! TIL, thanks 👍

@nblumhardt nblumhardt merged commit 3214c47 into serilog:dev Aug 25, 2022
@SimonCropp SimonCropp deleted the finish-nullable branch August 25, 2022 00:16
@nblumhardt nblumhardt mentioned this pull request Sep 12, 2022
Twinki14 pushed a commit to Twinki14/CitizenFX.Extensions.Client.Serilog that referenced this pull request Dec 30, 2023
* nullable in LogEventProperty

* nullable in JsonValueFormatter

* nullable in EventProperty

* nullable in LogContext

* enable nullable for EnricherStack

* remove "#nullable enable" and enable globally

* Update Logger.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants