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

Update Mvc to use LoggerMessageAttribute #38658

Merged
merged 11 commits into from
Jan 20, 2022
Merged

Update Mvc to use LoggerMessageAttribute #38658

merged 11 commits into from
Jan 20, 2022

Conversation

david-acker
Copy link
Member

@david-acker david-acker commented Nov 27, 2021

Updates the Mvc project to use the LoggerMessageAttribute for logging generation.

Description

The following files contained duplicate log event ids which had to be renumbered:

  • MvcCoreLoggerExtensions
  • MvcRazorLoggerExtensions
  • MvcViewFeaturesLoggerExtensions
  • RazorRuntimeCompilationLoggerExtensions

Also fixes a typo in a method name in RazorRuntimeCompilationLoggerExtensions:
ViewCompilerInvalidingCompiledFile --> ViewCompilerInvalidatingCompiledFile

Completes the Mvc task for #32087

@ghost ghost added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member labels Nov 27, 2021
@pranavkm
Copy link
Contributor

@david-acker are you manually updating these logger messages? I used a code-fix to do this in the past because it's far too easy to introduce errors / typos with such a large number of messages and it's incredibly difficult to review these in a PR. https://github.com/pranavkm/LoggerConvert has a version of the codefix, perhaps you want to give that a go (in a separate branch so you don't lose these changes)?

@david-acker
Copy link
Member Author

@pranavkm Ah, a code fix definitely seems like the best way to handle this. I just wrote a script to generate the logger message attribute and partial methods from the original LoggerMessage.Define implementations, although I did manually go through and remove the original extension methods which were replaced by the new logger messages.

I'll go back and use the code fix you created just to ensure that no errors or typos will slip through.

@mkArtakMSFT
Copy link
Member

Thanks for your PR.
@pranavkm can you please review this? Thanks!

@david-acker david-acker marked this pull request as draft January 3, 2022 01:08
Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

@david-acker these changes look good. If you'd like to make this PR non-draft, I'd be happy to get it merged.

@david-acker
Copy link
Member Author

Sounds good! There's still a decent amount of the original LoggerMessages in MvcCoreLoggerExtensions that still need to be converted, but it might be best to leave that for another PR to keep to scope down.

@david-acker david-acker marked this pull request as ready for review January 20, 2022 13:02
Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

Thanks! We can always tackle the remaining messages iteratively.

@pranavkm pranavkm merged commit bc1efeb into dotnet:main Jan 20, 2022
@ghost ghost added this to the 7.0-preview1 milestone Jan 20, 2022
@HaoK
Copy link
Member

HaoK commented Jan 20, 2022

@pranavkm
Copy link
Contributor

On it.

@david-acker
Copy link
Member Author

@pranavkm Just put up a PR to fix this. Odd that the previous CI runs didn't catch this.

@ghost
Copy link

ghost commented Jan 20, 2022

Hi @david-acker. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context.

@david-acker david-acker deleted the mvc-loggermessage branch January 20, 2022 22:00
ShreyasJejurkar pushed a commit to ShreyasJejurkar/aspnetcore that referenced this pull request Jan 22, 2022
Updates the Mvc project to use the LoggerMessageAttribute for logging generation.

## Description

The following files contained duplicate log event ids which had to be renumbered:
- MvcCoreLoggerExtensions
- MvcRazorLoggerExtensions
- MvcViewFeaturesLoggerExtensions
- RazorRuntimeCompilationLoggerExtensions

Also fixes a typo in a method name in RazorRuntimeCompilationLoggerExtensions:
ViewCompilerInvalidingCompiledFile --> ViewCompilerInvalidatingCompiledFile

Contributes to dotnet#32087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants