Using quick actions
Another handy tool that I like to use is the Quick Action tool. Appearing as a screwdriver (), a lightbulb (), or an error light bulb () on a line of code, quick actions enable you to use a single command that will generate code, refactor code, suppress warnings, perform code fixes, and add using
statements.
Look at the screenshot shown in Figure 10.4:
Figure 10.4: The VS editor showing the Quick Action Bulb
The GetMailMessage
method in the DemoWorker
class has line 30 highlighted with a lightbulb in the left-hand margin:
Figure 10.5: The Quick Action tool displaying quick actions that can be performed on line 30
We can see that we have several quick actions available to us that we can perform on line 30. Object initialization can be simplified, we can use an explicit type instead of var
, introduce a local, introduce method parameters, and even suppress configuration issues. Using these suggestions...