 Hey, everybody. My name is Leslie Richardson. I'm a Program Manager on the Visual Studio debugging and diagnostics team. And in this video, I want to talk a little bit about the new search feature for the autos, locals, and watch windows in Visual Studio 2019 and why you should ultimately use it because at the end of the day, it can help save you a lot of time and make you more productive while you're debugging. So in order to showcase this feature, I have this .NET Core application in Visual Studio 2019 here and I also have this list containing a bunch of different recipe objects. So in this case, I just want to go through all of these recipe objects and locate individual ones. But at first glance, the moment I expand this, I am ready to be annoyed because I have 61 objects contained in this list. So if I wanted to, for instance, find all recipes containing salad, I'd have to expand each one of these, locate its title property, which is all the way at the bottom here. And whoops, this one is not a salad recipe. So I'm going to have to go back, rinse and repeat until I find all of the particular, all the objects that I'm interested in. So this is going to take a lot of time. It'd be one thing that this list contained 10 or less items, but unfortunately, this is a larger list containing 61 different items and a lot of properties under each object. So there are a couple of things that I'd like to do to help make my watch window experience in this case a lot easier. So the first thing I'm going to do is use an attribute called the debugger display. And this is a feature that will allow me to customize how I view my objects in the watch window, autos window, locals window, data tips, and any other debugger window. So to demonstrate this, you'll notice that in the value column here, I am just being shown the type of each object, which I kind of already knew. So it would be a lot more helpful and useful if I got more specific info and was able to view each object by their particular property rather than a type. So I can use debugger display in order to do that. So I need to go to where I first defined my class. And at the top of the class definition, I'm going to add some debugger display syntax. And I'm using curly brackets here to return the value of a property that I want displayed in these windows. So because I want to view each recipe by their title, I'm going to use the recipe title property here. And I modified my code so I need to hit restart. And that should give me more useful information. So debugger display is a feature that is available for managed code users. So if you see C sharp, F sharp, or visual basic and are debugging in any of those languages, then you should definitely try this out. But if you're a C++ user and are wondering, is there an equivalent feature that you can use, I'm pleased to tell you that there is. It's called NATVIZ. And the main difference between NATVIZ and debugger display is that you're going to have to create a separate NATVIZ file. And it's basically just some XML where you can add in properties that you want displayed in any of these debugger windows. So here's the magic of debugger display. Because when I expand my recipes list here, you'll notice that I've gotten a lot more helpful info here. I can see each object by their title right off the bat. So I don't have to expand each one of these to find what I'm looking for. So from there, it should be a lot easier to locate each item by their specific properties or keywords. So if I wanted to find the recipes that contain salad in them, it would take a little less time, but because there's still 61 items, it's still going to take some time and it'll be a little tedious. So this is where search for the watch window kicks in. And instead of scrolling for what I want, or expanding for what I want, I can just search for it instead. We're going to type in salad and hit enter. Immediately it'll take me to the location that matches my keyword, which saves me a whole lot of time. Super helpful. And if I wanted to find any other matches that Visual Studio found for me, I can hit find next. And it will take me through all of those as well. So if I wanted to navigate backward and forward through this list of matches, I can change my search depth to one. And what that's doing is I'm changing how thorough I want my search to be. When I had my search depth at two, Visual Studio is essentially performing a depth-first search through each object. So it's going to go two levels deep into one particular object. And then it's going to return back to that root node for that object and then go to the next one and so on and so forth until it finds matching keywords. So with the search depth of one, I can scroll backwards and forward through all of my recipes containing salad. Awesome. So from there, let's say I wanted to locate another property, like extended ingredients. So again, I can search for it. Only this time I'm getting a notification telling me that no matches are found. But the first suggestion that it gives me is maybe I should change my search depth to a larger number. And in order to do that, or by doing that, I am telling Visual Studio to perform a more thorough search. So I'm going to bump up my search depth from one to three because extended ingredients is a property that is nested a little bit deeper inside each of these objects. And when I hit Enter, I'm taken to that same matching keyword, which is awesome. Again, I don't have to expand each individual object. I don't have to scroll through all of my objects or scroll through all of these properties until I find the one that I want. I can just use search like I would in any other typical search engine, which is fantastic. It's honestly amazing that we as human beings have managed to live this long without having search engines for the longest time. I still don't know how I did it. Just 10 plus years ago was crazy. Alright, and that was search for the autos, locals, and watch windows. So this is a Visual Studio 2019 exclusive feature. If you've been trying it out and you're super excited about it and are ready to make your life a bit more productive when you're constantly having to inspect hundreds of items in the watch window, then you should definitely check this out if you already have 2019 installed. But if you don't have Visual Studio 2019, you can go download it at visualstudio.com. And with that, happy coding.