Provide new EventId implicitly with tuple syntax#2543
Provide new EventId implicitly with tuple syntax#2543lodejard wants to merge 3 commits intodotnet:release/3.1from
Conversation
An `(int, string)` tuple may be provided where an EventId parameter is expected. Fixes dotnet#2542
- changes string literals with nameof reference - favor value-tuple assignment over `new EventId` for struct initialization
- adds implicit operator
| { | ||
| public static readonly EventId HealthCheckProcessingBegin = new EventId(100, "HealthCheckProcessingBegin"); | ||
| public static readonly EventId HealthCheckProcessingEnd = new EventId(101, "HealthCheckProcessingEnd"); | ||
| public static readonly EventId HealthCheckProcessingBegin = (100, nameof(HealthCheckProcessingBegin)); |
There was a problem hiding this comment.
I would avoid nameof here.
There was a problem hiding this comment.
Oh, I see what you mean. Although if the shape of logging is considered a contract that shouldn't change - there's probably several details that might be changed accidentally as easily. Using string instead of nameof doesn't seem like a strict enforcement...
Just thinking out loud, I wonder if there would be a convenient way to validate that logging contract hasn't changed in the unit tests?
|
Note that some sources edited in this PR has migrated to dotnet/aspnetcore. A new PR with the same changes for the affected sources should be opened in dotnet/aspnetcore. See #2974 for details. |
|
As per aspnet/Announcements#411, we are currently migrating components from this repository to other repositories. This PR targets components that have been moved to dotnet/aspnetcore. If you're still interested in contributing this change, please retarget your PR to dotnet/aspnetcore and reference the original issue discussing the change or bug fix. If you have questions, or need guidance on how to port your change, please tag |
An
(int, string)tuple may be provided where anEventIdparameter is expected.Fixes #2542