Frequently used features for solid and fast code on Visual Studio 2022
Abstruct
This article organises some useful and complimentary features on Visual Studio 2022 to embody clean code.
Code analysis
- Estimates the cleanliness of your code machinary
- It's better to reconsider the code architecture if the Maintainability Index got under 40.
- Useful for:
- Sniffing out the scent of technical debt
- Use as a reference to determine standard to address
- Menu:
-
Analyze
->Caliculate Code Metrics
->For Solution
-
- Result:
Code cleanup
- Clean up the codes through the entire solution
- Apply it before commit
- Useful for:
- Integrated format standard throughout a team
- Menu:
-
Analyze
->Code cleanup
->Run Code Cleanup (Profile 1) on Solution
-
Performance profiler
- Can monitor the performance of various resource
- Database
- File I/O
- CPU / Memory Usage
- Useful for:
- Finding bottle neck
- Detecting anormaly behaviours
- Menu:
-
Debug
->Performance profiler
-> Check the resorces to monitor ->Start
button
-
Configuration
Monitoring
Monitor
Metrics
Shortcuts
Search
effect | short cut |
---|---|
Jump | Ctrl + G |
Go To Definition | F12 |
Go To Implementation | Ctrl + F12 |
Navigate Backward | Ctrl + - |
Find All References | Shift + F12 |
Quick search | Ctrl + F |
Search in Folders | Ctrl + Shift + F |
Code Search | Ctrl + T |
Tips: Code Search is good, all the time.
What's the difference between Search in Folders
and Code Search
?
- The answer is:
-
Search in Folders
: String-based search -
Code Search
: Signature-based search
-
So it skips searching for redundant lines like comments and navigate you to your target line more directly when you use code search.
I strongly recommend to use code search if you don't require complex regex search or searching comments.
Edit
effect | short cut |
---|---|
Format Document | Ctrl + K, Ctrl + D |
Select word | Ctrl + W |
To Uppercase | Ctrl + Shift + U |
To Lowercase | Ctrl + U |
Move row |
Alt + ↑ or Alt + ↓
|
Duplicate row | Ctrl + D |
Complete word | Ctrl + Space |
Insert Block | Ctrl + K, Ctrl +S |
Tips: Insert Block is God
Haven't you used yet? Why?
Insert block provides with a variety of general snipet such as for
or if
.
Don't write by yourself but count on your IDE. It booms your productibity more than 10 times!
Refactor
effect | short cut |
---|---|
Rename | Ctrl + R, Ctrl + R |
Extract | Ctrl + R, Ctrl + M |
Quick Action | Ctrl + . |
Tips: Move a literal into a constant
- Select the target literal
-
Ctrl + .
and call Quick Action - Choose
Introduce constant
- Rename the constant
Build / Debug
effect | short cut |
---|---|
Build | Ctrl + Shift + B |
Start Debug | F5 |
Step over | F10 |
Step in | F11 |
Toggle breakpoint | F9 |
Toggle enable breakpoint | Ctrl + F9 |
Presentation
effect | short cut |
---|---|
Zoom In | Ctrl + Shift + > |
Zoom Out | Ctrl + Shift + < |
Conclution
Visual Studio is a rich and reliable IDE for .NET Developer. I love it and am honing my skills to be a good pilot for it.
But actually, I have some pains in the ass for it and expect Microsoft would modify/add new feautures like below.
- Gimme default reporter of test coverage.
- Why don't you add CamelCase/SnakeCase converter?
- Let me jump to Implementation when I
Ctrl + Alt + Left click
the signature like Resharper! - Keep displaying Quick Action while I'm taking screenshots.
Discussion