Wednesday, February 4, 2026

Debugging Tips and Tricks in Visual Studio 2022

>> Hello everyone.
My name is Hashada.
And today I will be sharing some of
our recent updates in
Visual Studio Debugging
and diagnostic space.
Let's get started into the demo.
Here I have an open source
application called ShareX.
It runs on your local and let's take
screenshots on your screen
or perform different tasks.
When I was working
around this application,
I noticed a inconsistent
bug sometimes when I was
trying to launch that it's not
able to find a local path.
I started my investigation ended up
on this method for
Update Personal Path.
When the name and
the code looks like
somewhere here we're setting a path.
It is a placement breakpoint
here on-line 462.
As I mentioned, the
pair was inconsistent.
I didn't want this breakpoint
of it every time when
I run my application.
I thought, why not convert this
to a conditional break point.
I'm going to go to settings
and select conditions.
Now as you know, conditional
breakpoints are really great
if you are to be in control of
execution of your breakpoint.
You can decide when and when
not the breakpoint can fit.
But sometimes coming up with
those conditions even remembering
syntax or understanding
different options
is not always straightforward.
And that's why I'm going to
ask Copilot for a help here.
As soon as I place my cursor,
you can see Copilot works in
the background and provides me
with these three
expression suggestions
which might work for my code here.
As I'm very familiar with this code,
I'm going to go with the first one.
You can even create
your own condition if
you don't want to use
the Copilot suggestion.
These expression suggestions also
works great with
actions or trace point.
Copilot actually can suggest some of
the status messages
for your application.
I'm going to close here
and you can see now
my breakpoint point is a
conditional breakpoint here.
As you're talking about
breakpoints here,
do you guys could've had
a scenario when you are
actually debugging a
complex application or
you're debugging multiple
issues at the same time and
then you end up having this
huge list of breakpoints.
That list is definitely not very
easy to navigate or even manage.
I used to have that too.
But recently, I started
using breakpoint groups.
As you can see here in
my breakpoints window,
I already create many groups here.
Creating a group is super easy.
You can do that using this new drop
down box and select
break point group,
and moving the breakpoint
to a group is more easier.
You just need to select
drag and drop to the
breakpoint group you need.
Now, if I need to focus on
particular area of debugging,
for example, for this demo,
I'm not really interested in any of
these non-demo breakpoint list here,
I can actually disable this
whole set of breakpoints in
a single click and I can focus
an area where I need to.
In our recent preview
release that is 17.11 P2,
we added another improvement
here that is called
default Breakpoint Group.
You can select any of
the existing group and
mark the breakpoint group
as default, like this.
What it does is, after this
any of the Breakpoints
which are created,
will get automatically added here.
For example, I'm going to
place a random Breakpoint here
on-line 459 and you can
see that gets added here.
This makes it more easier to work
around Breakpoints and also
around Breakpoint groups.
Now as we have looked
into Breakpoints,
let's continue further and
see what else we have.
Another thing I wanted to show you
here is this particular method.
Looks like we are setting
up some of the tasks
which we can perform
under this application.
I was more interested to see
different values which are
coming in this variables.
Instead of havarding
over each of them,
what I can do is I can
actually havard over
this object and use
IEnumerable Visualizer.
As you can see, I can see all
the data in just single view.
If you don't know, Visual
Studio actually supports
many different types of debug
visualizers such as HTML,
JSON, XML,
DataSet and IEnumerable Visualizer.
And, we recently made all of
our [inaudible] as non modal.
What it means is that you can
keep it handing like this,
or you can actually go
to this drop down menu,
dock it as a window,
or dock it as a tabbed document.
And the best part is, you can still
interact with the
editor in the back.
I'm going to comment out
this particular item here.
Continue my debugging and you can
see the real time change here.
You can actually also use
multiple types of visualizers
at the same time.
You can have a Text Visualizer
and IEnumerable Visualizer
open at the same time.
Maybe even the different screens
and it will still work fine.
Again, in our recent preview
release that is 17.11 P2,
we added another handy feature
and that is this
expressions textbox here.
This expression textbox,
let's write your own link
queries to filter on data.
Now I have a very small data here,
but imagine in the data with
hundreds and thousands of rows.
Having your own query
will make it super
easy to filter out on
the way you want to.
I'm going to write a
very simple link query
here or link expression
here to filter out my data.
As soon as I hit
enter you can see it
automatically filters out
the data however I want it.
That's what I have for today.
There are many other
Copilot assisted features
which we released
recently in our 17.10 GA.
If you haven't already,
please check out
our GA blog and learn more
about exception assistance,
deadlock detection and
profiler auto in sites.
Thank you. Thank you for joining

No comments:

Post a Comment