Hello and welcome to a new C# tutorial, lets’s take a look at an amazing Visual Assist for Visual Studio C#! This is going to be another special tutorial that is sponsored by Whole Tomato from Idera.
While using their visual assist plugin you capitalize on :
- Fast code navigation.
- Code inspection and modernizing old code.
- Refactoring will help you reduce the complexity of your code.
- And my favorite one, code correction. You will literally see Visual Assist correct mistakes as you make them.
- Code Assistance, that actually works and doesn’t get in your way !
So let’s get started!.
Downloading Visual Assist.
Download visual assist from here.
You can try it for free.
It does not matter which version of Visual Studio you are using.
All visual studio releases from 2005 to 2022 are actually supported!.
Download the free version.
Fill in your data.
Open the installer once it’s downloaded!.
You will see a list of VS versions you have on your machine, and you will get to choose which ones you want to install visual assist for.
I have 2022 so I will select that and click install.
To show you the full potential of VA we will be using an already prepared WPF project which you can download here.
29.WPF MC – Chapter 29 App Style.zip
You will be welcomed by the tip of the day from visual assist.
Which is a good indication that it’s working perfectly.
Run the app so we can take a quick look at what we have.
It’s an app that represents an App store like Google’s Play Store for example.
The New IDE Features.
Now let’s open the mainWindow.xaml.cs file to check out the code in there.
For starters let’s add a button to execute some logic, we will give it a text that says Click Me.
You will notice immediately that the theme or the color of the code is now different!.
And now it is much easier to distinguish between objects, methods, and classes.
But before we move any further let’s see how VA changed Visual Studio.
Under Extensions →VA Assist X.
Or if you are using an older version of visual studio, you might see it between View and Project.
You will use this menu to open the tool windows, review keyboard shortcuts, and access the options menu of Visual Assist.
While inside the MainWindow.Xaml file, you will see a new bar on top.
This is our new navigation bar if you click on the down arrow on the left.
You will see all the main tags in our Xaml, the window, the grid, and our button!.
This can be used to navigate faster in larger files.
For example, if we select the button it will take us to the button tag directly.
Now let’s look into some of the code features. So back to our MainWindow.xaml.cs file.
In our constructor, we will find a huge chunk of code which is basically events subscriptions.
Let’s add the following comment “Evnt Subscription”.
And as you can see it will immediately tell you that there is a spelling mistake in the word evnt
Now if you right-click on it it will show you the suggested corrections.
Add a new class called Animal which is going to be an abstract class. So it’s working just like a word document.
And now let’s select the correct spelling.
Extracting Methods
Sometimes when writing code you feel like this block of code does not belong here anymore and it needs its own method, so let’s select all of our events subscriptions.
Hover over it and you will see a tiny arrow, click on it.
Then select extract method.
What this will do is it will extract the code put it in a new method and replace the code we selected with the method call.
So let’s call it InitializeEvents.
Hit OK and move the code back into the MainWindow Class, it should look like this.
IDE Features
One of the things that VA changed in our IDE is a new window called VA Outline.
It will highlight the current method that we are at in the editor.
And it if you double click on any method from the list, it will jump directly to it.
And from the VA View tab, we can view all the files in our project.
Let’s select the Reviews.xaml.cs
And it will take us directly to that file.
Top Shortcuts in Visual Assist
- Open File In Solution Dialog
Shift+Alt+O
This will open a dialog that will allow you to select any file in your project.
If we search for MainWindow.
It will show us the MainWindow.xaml.cs file, and if we select it, it will take us to it directly.
2. Find any symbol shortcut.
Alt+Shift+S
This will open a dialog that will allow you to search for any symbol which means any method property or a class in the entire project.
For example, if we search for “names”. It will take us to a list called names that is already defined somewhere in our project.
3. Go to implementation shortcut.
If you have a method call and you want to see the method’s body to inspect its code simply hit
Alt+G
4. View References.
If you want to stop chasing a method around, you can use Alt+Shift+G
Which will show you all the places a certain method is referenced.
5. Find the most related file.
Alt+O
This will open the most related file to the document you are currently viewing.
6. Find References.
To find all references for a certain tag for example select a button from our xaml window and hit
Alt+Shift+F
This is more powerful and faster than the one in visual studio.
7. View all methods.
If you are in the MainWindow.xaml.cs file for example hit Alt+M
This will list all the methods in the selected class.
8. Quick Rename.
Let’s say you want to rename the Main object in our MainWindow class.
Use Shift+Alt+R To do so, this will open the Rename dialog.
Let’s rename it to MainWindowPage instead.
Visual Assist Hashtags.
This is an amazing feature that will allow you to create hashtags for comments and navigate through them.
Using the VA View find the names list from earlier.
And let’s say we are planning on fetching our data from a database in the future, so not to forget where this must be done in the future we can use a hashtag called ConnectToDB.
Then we can use Shift+Alt+H
To view our Hashtags and find them.
This will make your life easier when you are working with different developers where you can assign tasks to them by name using a hashtag for example.
Conclusion
Alright, now we’ve seen how to install and use Whole Tomato’s visual assist to increase your productivity. There is a lot more than you can do with it, this was just a small collection of features that VA has to offer so use this link to download it, use it and fall in love with it as I did 💚.