Search code examples
c#visual-studioidevisual-studio-2019

Apply Visual Studio Quick Action on multiple entries


I am using Visual Studio 2019 and have some warnings in my code. For instance:

warning list

I could apply one at a time but I would like to use the recommended quick action for all of them.
How can I do that?


Solution

  • A code fix is available for this rule in Visual Studio. To use it, position the cursor on the string literal and press Ctrl+. (period). Choose Use nameof to express symbol names from the list of options that's presented.

    enter image description here

    The thing to note is use the Fix all occurrences in whatever option you want.

    • Document - will replace it in the current file
    • Project - will replace all string literals in current project
    • Solution - will replace all string literals in entire solution