13 Visual Studio 2022 Tips & Tricks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
many.net developers use visual studio as their integrated development environment visual studio has many features designed to simplify developers lives and be more productive in this video i want to show 13 tips and tricks to improve your developer experience hi and welcome back if you're new to the channel i'm a software engineer with more than 10 years of experience with the net platform on this channel you'll learn all about net development depending on your experience as a net developer you might know and use some of the tips in this video however i'm confident that you'll learn at least something new before starting with one of the best productivity features listen to a quick word from today's sponsor visual assist is a visual studio extension filling gaps for c-sharp and cnc plus plus developers visual assist adds additional code navigation options to make your life easier code inspection and advanced refactoring tools help you improve your source code's readability and overall quality code correction corrects mistakes as you type for example you can type in lower case and visual assets automatically fixes your code visual assist adds additional code assistance features including intelligent suggestions while typing and it offers unique features for unreal engine development visual assist boosts your developer productivity check out visual assist using the link in the video description and download your free 30-day trial today when working with apis we often send a request and receive json data using c-sharp we need to transform the data into an object tree that's where what i'm going to show you is a game changer first let's assume we receive the following json data from an api now let's copy the json data into the clipboard and in the edit menu select the paste special menu and click on paste json as clauses as you can see visual studio generated a class structure matching the json data imagine how much time and tedious typing work you'll save if you have a big data structure visual studio also can do the same for xml data you can use shift plus alt and use the arrow keys to vertically select text let's assume you have a few lines and want to apply the same changes for example you have a few lines of console.writeline statements and you want to use console.write instead we press shift plus alt and use the arrow up key to expand the cursor to all lines we want to change next we apply our changes we can even move the cursor using the left and right arrow keys as you would with a normal cursor if we want to leave the vertical text selection mode we press the escape key if we want to mark a line for future edits we can use commands and mark them using the same structure for example we can add a command starting with to do and add a colon bookmarks are a better solution wherever we are we can hit ctrl k and k to bookmark a line in the solution we can open the bookmark window using the menu or using the ctrl w b keyboard shortcut this window provides an overview of all bookmarks and you can rename them using more descriptive text one thing to mention is that bookmarks are stored locally which means they are not shared using source control so if you want to share something with the team comments within the source code are the better choice however usually bookmarks are used for short term notes to yourself and you avoid accidentally committing your personal notes into the source code repository code snippets are a powerful tool for everyday code writing most developers know about the ctr code snippet to create a constructor or the prop snippet to create a class property however there are many more snippets that you can use to simplify your everyday tasks i'll quickly go through a few snippets i think are useful but not well known cw creates a console.writeline statement try creates a try catch block four creates a for loop with a predefined index variable incremented by one for r creates a for loop with a predefined index variable decremented by one exception creates a template for an exception implementation according to guidelines there are many more useful code snippets in visual studio i challenge you to explore them yourself or create custom code snippets in the code snippets manager specific to your projects code formatting improves readability and also helps to reduce code changes reflected in source control the keyboard shortcut control plus k d allows you to format the open document according to the rules set in the editor config file or the visual studio settings for example this method definition can quickly turn into a well-formatted piece of code this tip is almost an extension of tip 5 enable code cleanup on save it used to be a feature of the well-known productivity power tools visual studio extension however starting with visual studio 17.1 it is part of the core visual studio experience first we open the analyze menu and select the configure code cleanup menu item in the code cleanup submenu there is a list of available fixes and we can create profiles that include the code fixes we want to execute to enable code cleanup on safe we open the options dialog in the tools menu in the text editor section we select code cleanup we enable codecleanup on save by checking the checkbox using one of the previously defined code cleanup profiles we often navigate from one file to another using the mouse is not only inconvenient but also slow visual studio supports control plus tab and ctrl shift plus tab hotkeys like browsers do we can use those shortcuts to navigate through the open files within our solution visual studio provides a window that lets us select the desired file it is helpful when there are many files opened in the solution one of my most used shortcuts in visual studio code is ctrl t which allows me to search for a file using part of its name we can configure visual studio to allow us not only to search for files but also types to set it up we open the options dialog in the tools menu we then search for the edit dot go to all command and assign the control plus t shortcut to it back in the solution we can use the control plus t shortcut to open a little text input which works the same as in visual studio code working on bigger solutions can be challenging there is an option to track the active item in the solution explorer we open the options menu again and select the projects and solutions item we enable the track active item in solution explorer to enable it now whenever i change the active file in the editor the opened file is selected in the solution explorer when working with bigger solutions we can experience long loading times visual studio 2022 and even visual studio 2019 did a good job in reducing the solution and project loading times however there are two options we can enable to make it even faster we again open the options menu and select projects and solutions we disable the reopen documents on solution load and disable restore solution explorer project hierarchy state on solution load both options are convenient but most of the time you don't want to continue working where you left the solution anyway if you have to deal with bigger solutions try it out and let me know in the comments if and how much your solution loads faster whenever we copy and paste code we need to add the missing using statements we can enable an option to automatically add using statements let's open the options dialog again and select text editor c-sharp advanced we scroll down until we see the using directive section of the settings page we enable the last option to add missing using directives on paste if you want you can also enable the first option to place the system using first when sorting usings if you work on a solution for a long time chances are that you still have references to packages or projects that you don't use in your code anymore let's for example install the newtonsoft.json package in the nuget package manager for our project in the solution explorer we open the context menu of our project and select remove unused references visual studio analyzes the solution and suggests what references to remove from the project we can set the action for each reference and apply them all using a single bottom click when working with data clauses we usually have a few properties and we want to create the constructor sooner or later we can do that using the quick fixes menu we access it using the ctrl plus dot keyboard shortcut let's create a constructor including the name property now let's do the same on the date of birth property but this time we add the property to the existing constructor it's a small thing but the time saved can add up over time what we also can do using the quick fixes menu is generate argument null checks we place the cursor in the constructor argument and open the quick fixes menu again we select the desired option to generate the checks we need don't forget to like and subscribe and let me know in the comments what tip or trick you learned from this video or if i missed something important
Info
Channel: Claudio Bernasconi
Views: 39,122
Rating: undefined out of 5
Keywords: Visual Studio 2022, Visual Studio 222 Tips and Tricks, Visual Studio 2022 Productivity, Visual Studio Tips, Visual Studio tricks, Visual Studio Tips and Tricks, Visual Studio Options, Visual Studio Settings, Paste JSON as Classes, Vertical Text Selection, Using Code Snippets, Format Code, Enable Code Cleanup on Save, Bind Go to All, Track Active Item, Faster Startup, Add Missing Using Directives, Remove Unused References, Quick Fixes, .NET, CSharp, C#, Claudio Bernasconi
Id: etHfCFwH6MY
Channel Id: undefined
Length: 11min 12sec (672 seconds)
Published: Mon Apr 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.