Skip to content

Conversation

@lodejard
Copy link

An (int, string) tuple may be provided where an EventId parameter is expected.

  • Encourages use of named events by reducing typing
  • Compatible with EventId flavor of existing extension methods

Fixes #2542

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));
Copy link
Member

@Kahbazi Kahbazi Oct 25, 2019

Choose a reason for hiding this comment

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

I would avoid nameof here.

dotnet/aspnetcore#11379 (comment)

Copy link
Author

Choose a reason for hiding this comment

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

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?

@JunTaoLuo
Copy link

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.

@ghost
Copy link

ghost commented Mar 26, 2020

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 @dotnet/extensions-migration in a comment and we'll try to help.

@ghost ghost closed this Mar 26, 2020
@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants