Introduction

Debugging is a feature of Visual Studio by which we can see the program code step-by-step. It allows the developers to watch how the code works in a step-by-step manner, how the values of the variables change, how the objects are created and destroyed. We can apply the debugging to programs using Breakpoints in the project's code files by specifying the element code <compilation debug="true"> in the application config file. Visual Studio has a debug toolbar that provides all the tools available for debugging.

Diagnostic information could include the amount of time needed to execute a critical method, the number of transactions committed per second, or the number of users currently with active sessions. To facilitate the recording of diagnostic information, we have some software tools like: log4net. WCF diagnostics provide End-To-End tracing that provides instrumentation data for troubleshooting an application without using a debugger.

BreakpointFirst

Improvements in Visual Studio 2015

Microsoft announced some improvements in Debugging and Diagnostics features of Visual Studio 2015, at the day of Visual Studio Connect() from New York, USA on November 12, 2014. In Visual Studio 2015 Preview we will get the following improvements:

Debugging with Lambda expression

Now we can debug the code expression written in LINQ or Lambda with Visual Studio 2015 Preview. Prior to this version, .NET Framework (v4.6), debugging of a lambda or LINQ was not possible. So, let's learn how to debug LINQ expressions of as well Lambda expressions. When using a LINQ or Lambda, the debugger will quickly discover the dreaded message “Expression cannot contain lambda expressions”. Let's see that in an example.

Example

LambdaDebug

Limitations: Debugging with a lambda expression has some limitations, in other words:

Debugging with LINQ Query

In Visual Studio 2015, we can debug the Language Integrated Query (LINQ) Query. It works with LINQ statements, including stepping, setting breakpoints and viewing the result in a debugger window. A LINQ query is not evaluated until it is created or declared just before the writing query. Therefore, the query doesn't have a value until it is evaluated.

Example:
  1. Function MyFunction(ByVal x As Char)
  2. Return True
  3. End Function
  4. Sub Main()
  5. 'Query creation
  6. Dim x = From it In "MyCollection"
  7. Where MyFunction(it)
  8. Select New With {.a = it}
  9. ' Query execution
  10. For Each cur In x
  11. Console.WriteLine(cur.ToString())
  12. Next
  13. End Sub

Limitations: It has some limitations, as given below:

Breakpoints Configurations

Visual Studio 2015 provides a new breakpoints configuration windows that makes it easy to customize breakpoint behavior by specifying conditions and actions. where "Conditions" specify boolean properties that must be true for the debugger to break at a selected line. Conditions may have the following properties:

Debugging support for cross-platform

With Visual Studio 2015, we can create and debug native mobile apps that can run on Windows, Android and iOS devices. We can use the Microsoft Emulator for Android apps, or use own device (mobile.tab) and for debugging our code directly. We can use the following to develop the application for cross-platform.

C++ debugging enhancements

Microsoft enhanced the debugging features of C++ in Visual Studio 2015. The following are the two major enhancements in it.

Summary

In this article we saw the enhancements of Debugging and Diagnostics in Visual Studio 2015 with details. In a future article we will explore it more.