TracePoint : An awsome feature of Visual Studio

Have you ever wanted to see the intermediate values of a variable which is inside a loop without pausing the execution via breakpoint?

I am sure you will say YES. A visual studio feature called Tracepoint can be very helpful in these scenarios.

Breakpoint allows to stop at a point where you can see the variable value but you may loose the track of it loops for more than 4-5 times.

Tracepoint is an awesome feature of Visual Studio and it is available since Visual Studio 2005. It allows you to write the values in output window without even stopping at any point or you can stop it after the loop and see how the loop progressed based on your needs. I recently started using it and found is very useful. I am sure it is relatively less used.

Let’s see an example. Here I have created a simple program which finds out the nth number in a fibonacci series. Lets see the code

Now I am going to set a tracepoint at line #41. To set up a tracepoint, one need to set up a breakpoint and right click on it which provides few options, then select Actions which opens window as

(In earlier versions of Visual Studio, the options was named as Choice which is Actions as mentioned above)

Here I have written i={i} => result={result} . The values insde {} are the variable names in the program and the value of these variables will be printed.

The messages will be logged in output window. See here the check box Continue Execution which is self explanatory. If you uncheck this then the breatpoint would be hit as normal and pause the execution. So lets run the program and see the output window

I have provaide value 7. Here you can see that the value got printed here for each loop iteration. This is quite useful if number are pretty high.

Debugging is also get tricky in case mutli-threading and asynchronous programming scenarios which is pretty common nowadays.

There are few others pseudo variables available which can be used display various other useful information as

Hope you have enjoyed the post.

Cheers,
Brij

Advertisements

[Video] Visual Studio Tips to make you Super Productive – Part 3

Hi All,

This video is in continuation of my last two video posts where we discussed some awesome visual studio tips which makes you super productive. In first video, we talked about tips related to Class and in second video, we discussed some other common tips for adding very common code snippets. Please find my previous two videos below

[Video] Visual Studio Tips to make you Super Productive

[Video] Visual Studio Tips to make you Super Productive – Part 2

In this video, we are going to discuss another 10 tips related to Visual Studio IDE which will help in day to day development, debugging, code review etc.

Use these tips in day to day activities and be few steps ahead 🙂

Cheers,
Brij

AngularJS in 19 Days : Download the free eBook with samples

Hello All,

As you might be following the series of posts on AngularJS from last couple of months and that I completed 20 post and covered range of topics. Based on many suggestions, I have updated all those posts with current version 1.4, since initial posts were using other using 1.0+, added navigation links etc. Now I have incorporated compiled all the posts, refined the content and sample a bit and happy to present it in a format of eBook. I am sure it will be very handy and easy to read and follow till end.

About the ebook :

ebookcoverFor those who were not following the series of post, As the name suggests this book in divided in 19 days from Introduction to covering most of the core topics including unit tests. The sample of each day can be downloaded from GitHub. This is not just another e book which covers the basics of AngularJS or cover everything, but it is a unique combination of basics and details description of core concepts with sample. If you are ASP.NET MVC developer then it will become more fruitful to you as some of days it covers that how and what are best ways to use Angular in ASP.NET MVC project. I am sure you will enjoy the book and will share your feedback that will help in upcoming new version.

 

Download the book from here

Thanks
Brij

Top 12 Visual Studio short cuts – Productivity Tips

Visual Studio is very Rich IDE and it provides in-numerous features that makes our day to day life easy. There are some very useful hot keys and tips which can increase our productivity significantly. Earlier I used few hot keys but recently I learned few which I found awesome which drastically reduce my time while writing/debugging/reviewing the code. So learn these and make a habit of these keys and feel super charged while writing code.

  1. While code review I find many time scattered and unaligned code which I hate. I use CTRL+K+D for aligning it.
  2. While debugging or testing the code, commenting/commenting codes are done a lot. Use CTRL+K+C/CTRL+K+U for the same.
  3. How do you up/down certain line of code. Select the code block and use ALT+up/down
  4. You have a used a lot F12 to go to Definition of class. Use CTRL – to go back.
  5. How do you resolve the classes by mouse click. Use CTRL+. to resolve it quickly.
  6. Refactoring is very important. Use CTRL+R+M for extracting a method.
  7. Find All References -> Use Shift + F12. Very helpful while debugging and fixing bugs.
  8. Want to put few lines of code in try block. Try Ctrl + K + S, it provides lot more options
  9. Ever tried selecting a rectangle code. Use ALT click drag.
  10. Lots of code in a single file. Use  CTRL + M + O and CTRL + M + X in collapse/expand code groups like regions, methods etc.
  11. Lots of code and there are no groups. Use CTRL+M+H/CTRL+M+U
  12. Another super sweet. ALT+F4 to close the window.

Try using the above in your day to day coding and be more productive.

Cheers
Brij

 

Task List window of Visual Studio

Recently, when microsoft launched Visual Studio 2010, they launched it with the very nice Campaign “Life runs on code”.Who all have seen the any advertisement of VS 2010, must have seen this also. It’s very true, we, developer’s life runs on code, and our code runs on Visual Studio IDE ( Obviously only on development phase 🙂  ).

As most of the time in our offices and home (only for workaholics 🙂 we spent most of the time with visual studio IDE, we always try to find some way to code faster/better, to increase the productivity.
Visual studio IDE is full of myriad features, that helps us for faster and smoother coding. We most of the time are not aware of this and don’t use these.I always try to find some good feature at Visual studio, which we can use in our daily life and share with you all.

In this post, I am going to discuss a window, that is called as Task List window, some of you might aware this so this for rest developers 🙂

So what is the Task window, how it can help us. Let’s go in bit detail

As we have other window, Error/Warning window, we also have Task list window.To see this window, Go To View->Task List or directly using the keys Ctrl+W, T. This task list window show us the TODO list that we track and other annotations. Task list window has two views : User Task Window and Comments Window. We’ll discuss first comments Window.

Generally, we write some TODO or UNDONE comments, while development phase of our application. These comments are a sign, that we need to update/Change the code before releasing to QA/Staging environment.

As in my sample project, I have added few comments multiple files. These are listed in the Task List window (Comment View). One can all the these type of of comments in this window from the entire project. And one can click one by one and make changes whenever required. Let’s see the comments…

Task List: Comment View

We can click on any of it and it will take us to directly that line of code.

HACK, TODO, UNDONE, UnresolvedMergeConflict are default comment Tokens in VS IDE. But one can add custom tag based on their requirements.Go to Tools-> Options then under Environment click task list as below ( If Task list is not visible make sure “Show all settings” checkbox is checked at bottom of Options window).

Options Wnidow

Options Wnidow

To add a Custom Token, write the Token at Name input box, set the priority and then click on add button.We can also remove/change the existing token with the given buttons.

Now lets move to User Task View, this view list down all the user created tasks. One can create user tasks by clicking Create User Task icon, just beside view dropdown. Let’s see it

Task List: User Tasks view

Task List: User Tasks view

This gives you option to write the description of the task and set the priority. Once the task get completed, then one can mark it as completed by checking the checkbox.

Note: I have VS2008 for this post.

That’s all for now!!!

Cheers!!

Brij