 No matter what your coding, what project you're working on, or what your development environment even is, I'm thinking it's safe to say that everyone wants to know how to be more productive. So find out some cool tips and tricks on how to do so on this episode of Visual Studio Toolbox. Hey everybody, welcome to Visual Studio Toolbox. I'm your host Leslie Richardson, and today I'm joined by Mika Dumont, who is a PM on the.NET team. How's it going Mika? Good, how's it going Leslie? It's going all right. It's a lovely sunny afternoon in Seattle right now. It is. Yeah. So you're a PM on the.NET team, which is such a broad giant team.NET is so huge, especially in Visual Studio World. So can you talk a little bit more about what is that you do? Yeah. So I'm a Program Manager on the.NET team and my team. What we try to do is we try to make developers.NET developers as productive as possible. So whether that's different code fixes or refactorings, as well as different like code generation and completions and tooling, we just try to give you all the productivity features in order to supercharge your developer productivity. I love that word supercharge. Yeah. So speaking of productivity, that's what we're going to be talking about, right? Yeah. Leslie, since you work on the debugger, I thought that I can go ahead and start with our debugger refactoring. So I'm going to go ahead and share my screen. There we go. So the very first feature that I wanted to show, again, this is brand new. It's a refactoring where you can pin properties programmatically in your code by adding this debugger display attribute. Oh, I love that attribute. Yeah. It's pretty awesome. This will also automatically generate a method, and its default return is two string. But if I want, I can actually go ahead and have it return the first element of an array. I'm going to go ahead and save that, and I already set my breakpoint over here, and I can just debug this test real quick just to show you what this feature does. So you already get the debonus points for me for starting your demo out with the debugger display or just anything debugger related, so congratulations. Cool. Yeah. So here you can see that the first value is a zero index of the array, which is this little dog emoji. So without having to go ahead and manually pin these properties using the Debye UI, I can just programmatically do that in my code. That's cool. Yeah. Just eat refactoring. That's neat. Yeah. Because now you can do it, you can have it both ways. So if you like debugger display as an attribute and you want to get crazy complex with it, then you can use that except now you can access that feature a lot better it seems. I love that you made that a refactoring option. Conversely, if you like debugging and you just like playing around in the watch window, then you can use that pin icon that Mika just explored. Yeah, exactly. The next one, I just says we're here. You might notice that we have a couple of these regular string literals, and it's, I don't know, Leslie, it's kind of hard to parse what this is saying, right? Yeah. How do you even know what to type in for that? Exactly. We actually have a refactoring now where you can actually convert this to a verbatim string, so it makes it a bit more legible. If I want, I can also convert it back to a regular string. That's just a neat new refactoring that we just added. That's really nice. Yeah. Because sometimes I might add an extra N or something or an extra backslash, and I don't know if it's actually going to work until I print it out or it goes wherever the string needs to be. Yeah. Now you can just easily see what you're typing and just switch around. Instead of having to process it every time you still pass that line, good grief. Yeah, exactly. While we're here, I do want to show you this one too. So I'm going to uncomment this. So the keyboard shortcut for toggle block comments is control shift forward slash and I just want to point that out. Here you might notice that I'm getting an error, and if I hover over this error, quick info is letting me know that this expression cannot be implicitly cast. Luckily, we have a code fix to add an explicit cast. Oh my. Yeah. That's so exciting. I think that is. Yeah. So I don't know if you're familiar with just having to go and hover over to learn what the typos that Claire does. This will just go ahead and serve that right up for you. That's what's so cool about refactoring tips like that. It's just they're small but mighty quality of life improvements to me that just make my life easier. Yeah. It's just the little things. Yeah. What else? I do want to point out, hopefully, you're pretty familiar or if the audience is pretty familiar with this light bulb icon. So this light bulb represents quick actions, and quick actions allows you to easily refactor, generate, or modify code with a single action. I can go ahead and invoke this by either selecting the light bulb icon or I can just type control period or alt enter and it'll also invoke it. This latest refactoring that we have is converting a switch statement to the new C sharp 8 switch expression. This will just go ahead and provide a more. Look at that. Yeah. It's like magic exactly. So this will just go ahead and provide a more concise syntax without having to write out the returns in each case. Right. It saves you a lot of trouble. Yeah. It also just helps you learn about new C sharp language features too. So it's pretty cool. I don't know if you notice all of these XML comments over here. Yeah. Always fun to write whenever you need to explain what a given class or method does. Yeah. We actually now have a quick info style support for XML comments. So if I go ahead and hover over this class, you will notice that quick info will display italics, bullets, numbers, bolds, and clickable link. Oh, that's really cool. Well, I'm talking about XML comments. Over here, you can see that this dog card is inheriting from this animal card class, and let's see. If I go ahead and add this inherits doc tag, you will see that dog card now will inherit from different base classes or interfaces, just depends where you want to add that inherits doc tag. So this just eliminates the unwanted copying and pasting of duplicate XML comments, and it will automatically keep your XML comments synchronized. Yeah, that's pretty sweet. So before that keyword existed, you'd have to remember to go back to the base class and update accordingly. Yeah, you would just have to copy and paste them in here if you wanted to remember. Yeah. Yeah. Time saver. Yeah. I'm trying to think what else I have that I can show you. Oh, so over here. Let's see. Oh, here's a good one. I noticed how I have comments just to remind me. I do that too, right? Demo and big bold letters. Yeah, exactly. Totally natural. Don't worry about it. Yeah, so anyways, yeah, this ternary condition. You know, ternary conditions can be great, but sometimes at the end of editing it's logic. You realize things could be a bit simpler. There's a lot going on here, you know? I feel like I always have to go on Stack Overflow and look up what does this mean again? Like what part is the L statement? Which part is this? Yeah, exactly. And we just want to make things easier to read and we just want our code to just be easily read and consumed. So we do have this code fix to simplify conditional expressions. And that just makes it so much easier. Oh, yeah. Like can you believe that they both meant the same thing? Right? Yeah. So you mean I just spent five minutes deciphering this just to find out? Yeah, like did your brain hurt a little bit? Like it's 2 a.m. I'm looking at this code. Yeah. So those are just some of the latest code fixes and refactorings. And next I want to show some tooling improvements. This one's actually my favorite one. So there was like tons of excitement from the community about this one. And so we pretty much, we added intelligence inside daytime and time span literal strings. So in this piece of code, I'm taking a daytime and I'm calling two string on it. And if I start typing a daytime string literal, you will notice. Yeah. Great suggestions. Yeah, these are completion options and explanations as to what each of these characters mean. So you can see here, this is what it looks like. So it's pretty snazzy. Yeah. And while I am talking about, you know, intelligence completions, and let me missing a quotation mark, I do want to point out, you know, we also have intelligence completion for regular expressions. So I can go ahead and just show you that real quick. Let's see. So here I'm just going to write a regular expression. And so notice how I get, yeah, a little bit old. Notice how I get these completion options and explanations as to what each of these characters mean. What's really cool too is that I also get a tool tip. So quick info will actually let me know if I'm missing, like I'm missing my closing parentheses. So it's pretty smart. It's really awesome. This seriously would have been so useful to me a couple of months ago when I was writing a calendar app and writing date formats everywhere and trying to look up what format I need to be using. Yeah. Oh my gosh. I actually remember that calendar app that you showed. Great. Also, yeah. It's like great. Good times, good times. Back in five years ago in March. I know, it feels like forever ago, it's great. Yeah. But yeah, so these are just nice inline experiences that we offer instead of having to go to the browser and learn how all of this works. So, yeah. Let's see. I have another tool tip. So we've had change signature for a long time where you can go ahead and reorder parameters or remove parameters. But we just recently added the capability to a parameter. So here, I can go ahead and add the type as well as the parameter name. I can also make this required or optional with a default value. And I can decide what I want to inject into the call site. And I can also introduce to-do variables. So this will basically put a to-do in my code so I can visit those errors and go through each call site independently and decide what needs to be passed. That's awesome. Yeah, and for optional parameters, I can also choose to omit the call site completely. So it's pretty cool. And once you select OK, you will see a preview of the new method signature. And you will see that this is the new parameter. So it's pretty awesome. This is one of our highest requests from the community. So we're really excited to get this one out. That's really great. So I especially like the adding the to-dos just automatically instead of having to remember where you call this function everywhere. That's pretty nice. Yeah, it's a pretty awesome new feature. Let's see. Oh, I have another one real quick too that I want to show. So we added file header support. And this allows you to add file headers to existing files within a project or a solution using an editor config. So this is an editor config file. For those of you who don't know, it's a single file that documents all of your code style or code quality options that lives at the root of your repository and can be managed by a regular source control and shared across your entire team. So you can think of it as a universal way of enforcing code style, code quality preferences across your team. Yeah, so it's pretty cool. And so here we have this file header template. And you would just have to set the value to equal the file header that you text that you would like to get applied to your C-sharp or visual basic files. This currently only works for C-sharp and visual basic. And if you go to the first line of your file, you can go ahead and select this file header. So let's see. Yeah, it's pretty awesome. And not only that, I just want to point out a lot of our code fixes, and for the file header feature as well, you can really actually apply all of these fixers to your entire document, project, or solution. So you can scope it however you'd like. So if I want, I can add this file header across my project. Yeah, and it will open this preview changes window where I can just select or deselect which files I want this to apply to and go ahead and do that. And you can see that it was added. And if I go to other classes, you can see that was added too. So it's pretty cool. That's pretty cool. Yeah, I'm going to add emojis to all my file headers and hearing out too. Yeah, that's the only way to write file headers. Yeah, it's really though. I messed it up a bit. Yeah. So I mean, it seems like there's a lot you can do in that editor config window in general, right? So how can people learn more about what they can and can't do when they're specifically? Yeah, well, we have documentation that I can always point users to. We also have for all the different code style options. You can go to Code Style. You can just use Control Q Search over there. And here you can actually, it's a little bit easier to understand this UI that we have. And you can actually see all the different code style preferences that you want and have it applied to your editor config as well. That's neat. Yeah, and so if you want, you can do tabs versus spaces. Oh, boy, yep. I don't want to bring anything up. I know there's a lot of controversy there. Yeah, and then, yeah, so you can just enforce these code style and code quality options across your team. So if you're really adamant about tabs, you can just sneak that word in there and then just cut your code out. We all just have to use tabs. That's like the dream of being a manager, right? You get to assert your belief of tabs versus spaces. Yeah. I have to see the editor config. Yeah, yeah. And yeah, and so we're doing a lot of work with this too. So stay tuned with the editor config. So yeah, it's exciting stuff happening with that. Yeah, it is. And so we have, oh, yeah, go on. Oh, I was just going to say, speaking of exciting things coming, I mean, it feels like I look away for five minutes and all of a sudden there's like 20 new cool refactoring items added. So what's coming soon in productivity land? Yeah, OK, let me show you. OK, so let's see. So some new features that are coming. The first one I can show is, so here we have, here, let's see which one should I show first. OK, I can show this one. So there's now a refactoring that introduces the new C-Sharp 9 pattern combinators. So over here, if I just place my cursor and select, let's see, use pattern matching, it will go ahead and use those pattern matching combinators. Yeah, so that's like a new C-Sharp 9 feature or the pattern matching combinators. So it's really exciting. And yeah, and another one that we recently just added. So these are all coming in 16.8 preview one. So everyone who wants to learn more about it can just check out the release notes as well. And yeah, and so this one here, so this is, we now have like a suppression operator warning and code fix, and this helps you easily identify and fix suppression operators that have no effect. So in this case, let's say, in this case, I wanted to express that something isn't type string. And so this operator here makes sense, but it's not actually checking for that. So we have a code fix where you can either remove the operator completely. Or if you want to actually check it, you can use the is not. That's if you're checking it. It's not of type string. Yeah. That's great. Yeah, so that's like a new one that we just came out with. And let's see, what else do I have here? We have another one where you can remove the in keyword where the argument should be passed by reference. So that's just also like a quick little fix too. And trying to think what else. So we have another one. Let's say here I can do it. Let's say I want to just go ahead and let's see. OK, let's say I want to just create a abstract method. Let's see. So over here, you'll just notice that I have an error. And that's because my class isn't abstract. So we have a quick fix to also make a class abstract. And you can see here that the error was added. No. Oh, wow. Yeah, that just seems something that would naturally be there. So I'm glad that's there. Yeah. Yeah, so those are some of the latest code fixes ring factorings coming to 16.8 preview one. That is very exciting. There is not a bad one in the bunch from what I could tell you. All of these seem super beneficial to anybody who's just coding away no matter what you're working on, which is the cool part about productivity tools like that. Yeah, it's really awesome. And I don't know if we have time, but I can also just show a couple in the solution explorer that was recently added that are just really cool. OK, yeah. So here I have a test project. And just for demo purposes, I'm going to delete this reference. So I'm referencing my project here. And so now I'm not referencing anything. And if I want to go ahead and add a project reference, I would have to go to add and then add the project reference. But we just added the ability to drag and drop the project you'd like to reference. And voila, notice how this project reference was added. And it was also added underneath the dependencies note within the solution explorer. Great. So no need to worry about syntax, typos, any of that. Yeah, just so you can just drag and drop. Yeah. And another last thing about with the solution explorer that I wanted to point out is we added the capability of copying, pasting, and dragging files from file explorer to solution explorer. So instead of having to right click and add an existing item, and we then have to re-navigate to where your path already is, you can now simply drag and drop this file and it will get copied right to your source. So it's pretty awesome. That is so great. Yeah, it's really cool. Rosh. Are those features available in 16.8 or are they already available? Yeah, they're out now. Yay. Yeah. How exciting. Yeah, it's pretty exciting stuff. Let's see. Yeah, and I think that's all I have today. But yeah, definitely check out the release notes. And also, all of our code fixes or backlinks are at ak.msbord slash refactor code. And so yeah, that's where you can just learn about all these new tips and tricks. And you can be the coolest person on your team that everyone goes to learn about that. Yeah. Just sitting in your office chair like, yeah, so did you know you can now drag and drop into the solution file? I mean, I figured everybody knew, but just in case you didn't, here you go. Well, that's really exciting. I'm going to have to make a trip to that website too, keep missing out on all these wonderful refactorings that I should totally be taking advantage of. And should everybody? Yeah. So thanks for being here, Mika. That was super informative. I feel super charged in my health experience, definitely. Thanks. And yeah, and again, if you want to learn more, check out the website that Mika just mentioned, ak.ms slash refactor code. Awesome. Yeah. And with that, happy coding.