-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Group 4] Enable nullable annotations for Microsoft.Extensions.Logging.EventSource
#66802
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
[Group 4] Enable nullable annotations for Microsoft.Extensions.Logging.EventSource
#66802
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-logging Issue DetailsRelated to #43605 Questions:
|
I would try cleaning my repo: |
| { | ||
| public EventSourceLoggerProvider(Microsoft.Extensions.Logging.EventSource.LoggingEventSource eventSource) { } | ||
| public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName) { throw null; } | ||
| public Microsoft.Extensions.Logging.ILogger CreateLogger(string? categoryName) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ILoggerProvider has categoryName as non-nullable. So this should be string categoryName.
We don't want to allow this to be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should EventSourceLogger.CategoryName be nullable then? Maybe it doesn't really matter sines it's an internal API, and nothing breaks when it's nullable, but still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should EventSourceLogger.CategoryName be nullable then?
I would say no. If nothing ever creates it with a null name, then I wouldn't make it nullable.
src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging.EventSource/src/ExceptionInfo.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLoggerProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs
Outdated
Show resolved
Hide resolved
|
/azp run |
|
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
|
/azp run runtime |
|
Azure Pipelines successfully started running 1 pipeline(s). |
eerhardt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the contribution here, @maxkoshevoi!
| if (command.Command is EventCommand.Update or EventCommand.Enable) | ||
| { | ||
| if (!command.Arguments.TryGetValue("FilterSpecs", out string filterSpec)) | ||
| if (!command.Arguments!.TryGetValue("FilterSpecs", out string? filterSpec)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place that concerns me. But if it hasn't been a problem, I guess we can just suppress the null check here. Looking around I see similar code elsewhere:
Lines 393 to 397 in c5d40c9
| if ((command.Command == EventCommand.Update || command.Command == EventCommand.Enable) && | |
| IsEnabled(EventLevel.Informational, Keywords.Events)) | |
| { | |
| string? filterAndPayloadSpecs = null; | |
| command.Arguments!.TryGetValue("FilterAndPayloadSpecs", out filterAndPayloadSpecs); |
runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs
Lines 53 to 59 in c5d40c9
| private void OnEventSourceCommand(object? sender, EventCommandEventArgs e) | |
| { | |
| if (e.Command == EventCommand.Enable || e.Command == EventCommand.Update) | |
| { | |
| Debug.Assert(e.Arguments != null); | |
| if (e.Arguments.TryGetValue("EventCounterIntervalSec", out string? valueStr) && float.TryParse(valueStr, out float value)) |
|
+1 we appreciate your hard work on all these annotations @maxkoshevoi . |
…ng.EventSource` (dotnet#66802) * Annotate src * Annotate ref * Make internal parameters non-nullable if they never receive null

Related to #43605
Questions:
Argumentscan be null hereruntime/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs
Line 303 in 731d936
maindoesn't help. Is there something I'm missing?