 We are going to move on today to increasing your.NET productivity with Visual Studio 2019 with our friends Kendra and Mika. Hey, hey. We have two stages, so sophisticated. Yeah. Smooth transition. Hi, I'm still Kendra Havens, and my name is Mika Dumont, and we're here to talk to you about increasing your.NET productivity with Visual Studio 2019. Yeah. So we have a ton to cover. We're going to first talk about Live Share, and then we're going to talk about code fixes and refactorings, analyzers, code cleanup editor config, the new code analysis project properties page, and then we're going to talk about IntelliCode Test Explorer, and maybe if we have time, we'll talk about some new preview features. Right. If you're good. Okay. So first off, we want to talk about Live Share. I'm going to go ahead and say, if we're repeating a lot of concepts today, and you've heard about Live Share before, or editor config or code cleanup, all of the stuff we're going to cover, we get thousands of new users every week, several thousand new users every week. So we want everyone to be on the same page. That's what we're going to do. Okay. So Live Share is an excellent tool for a collaborative co-editing experience. It's all about peer programming. So let me go ahead and start a Live Share session from my machine. As soon as I hit that button at the top right corner of Visual Studio, it generates a link. I'll go ahead and paste that link over to Mika in my favorite chatting app. If we go to Mika's machine, you can actually see when she clicks on this link, it will launch another instance of her favorite editor. So this one is set to Visual Studio. She can also join the collaboration session from Visual Studio by just pasting in that link. So when this loads, she'll get my full editing context. We'll be able to debug. I could step through her debugger. I'll know her variables. What else can we do? I actually can write code in Kendra's editor right now. So that's pretty sweet. No, you're leaving me something to do. Yeah. Okay. I need to tell you. You can see what I select. She has full access to my solution explorer. What else do we have? Yeah, and I also can access your terminal, as well as your server, all from Visual Studio. So share with people you trust. Yes, that's a lot of access. Okay, make sure you know these people. Cool. So I'll next talk about, we'll dive into the refactorings. Let's see. Code fixes and refactorings. There we go. Okay. So I have a ton on this slide. So these are only the top few that we've chosen from the last few releases ever since Visual Studio 16.0. We've released hundreds of code fixes and refactorings in the past year. So there's a very, very long list. All of them are covered in my docs. So please know that this is just like a small example of everything that you can access. So I'll go ahead and stop my live share session. Sorry, Mika. It's okay. Okay. So let's say you're re-architecting your app, and I might be having a problem with my display because I was using multi-desktop, and I was not communicating with the Channel 9 team which one I should be. But I can drag that over to my second desktop and just display that. Does that work? Oh, I should probably exit presenter mode. That's probably what I needed to do. There you go. Oh, worked for a second. Oh, this is all on me, and I was saying everything would go smoothly today. Maybe duplicate. Exit? Yeah, trying to get out of here. Do I want to keep ink annotations? I'm going to discard those. Okay. There you go. Okay. Now you can see this screen. Excellent. All right. So let's say I'm re-architecting my solution. I am dragging and dropping files into new folders, all of that. A lot of people want their namespaces to stay in sync with their file structure. So I can do that by placing my cursor in a namespace, hitting Control-dot, or opening this little screwdriver icon to show all of the available quick fixes and refactorings, and I can change my names as mean to match my folder structure. So we're automatically, we can read what folder structure you have and suggest the right naming that you want to use. Next one that I'm very excited about. So Mads and Bill just talked about switch expressions. So let's say I have a switch statement. I can now easily convert it to a switch expression with a clever little refactoring, and check this out. Wow. I know. It saves so many lines of code, much, much easier to read, refactoring, converting switch statements to switch expressions. So to use this, you do need to be using the C-sharp 8 features switch expressions. So go ahead and upgrade that. All right. The next thing I want to call out is, yeah, over here in Emoji search. Okay. So let's say that I'm importing something into a file. So let's say I'm trying to use JSON convert, but I don't have the using for newtonsoft.json that library at the top of my file. I'm still getting intelligence completions for this. This is completions for unimported types. So we're now able to offer all of the types in your intelligence list that exist in any of your dependencies on your project. So this makes your intelligence list a lot longer and a lot have a lot more options of what completions to offer. If you wanted your intelligence list to be scoped to only the things you have imported at the top of your file, you can use this little filter button to scope it again. Right. So if you liked using that before, you don't lose that functionality. So if I go ahead and accept that suggestion, you can see it also added the needed using. Yeah. Okay. So if I go ahead and write a bit more on the rest of this line, the next code fix and refactoring that I want to show is we have a ton of ways to generate different variables within your scope. The most recent one we added was generating a parameter. So then it automatically appears up in my findEmojis method. Pretty sweet. Let's see. What do I have going on here? I have a bunch of calls. In order to read calls a little bit easier, we now have wrapping chained calls. I believe this was a community contribution too. So thank you so much to the community. So now that I have these, I'm like, oh yeah, I'm actually have some needless duplication in there. I can go ahead and clean that up a little bit. Cool. So that was wrapping chained calls. Next up is toggling a single line comment. So we've had Ctrl KC, Ctrl KU for commenting for a really long time in Visual Studio. Recently we've added Ctrl Shift forward slash, that's the multi-line comment, as well as Ctrl K slash. So that'll comment the entire line. And if my cursor is anywhere inside that line, if I Ctrl K slash again, it will toggle that comment off. And now so if I have any selection, I can Ctrl Shift forward slash, and it adds a multi-line comment to the entire selection. And again, if I have my cursor anywhere within this block and hit Ctrl Shift slash again, it toggles off comments for the entire block. So this is a commenting method that they had in VS Code that was really popular, that we were like, well, let's add it. Let's add a few more keyboard shortcuts. All right. Next thing I want to show off is also suggested by the community. So this is splitting and merging if statements. So if you have an if statement with multiple suggestions, or multiple conditions, you can actually split it into two nested if statements, which is pretty sweet. Yeah, I love that feature. Right, and if I wanted to say, I had a lot of if statements and I wanted to say, hey, can I actually merge any of these? You can also merge with your outer if statement. Pretty cool. All right. So you might have noticed I have actually had, well, first off, I have some unsorted usings. This is kind of hard to look at. Why don't I go ahead and use Ctrl Q, and I'll go ahead and search for sort usings. So we've added the sort usings command. Didn't we already have that? Yes. So it might look kind of familiar. And this is actually a good point for saying that feedback is so, so important to us. So we knew that remove and sort usings were called almost all the time right next to each other. So we were like, why don't we just combine these two into one command? So we did. And then we got lots of feedback that that wasn't the right thing to do that. So just checking to see if everyone's awake. Thank you for feedback. We added it back in as a completely separate command because there were totally scenarios that people wanted to sort usings without removing everything that they had there. So I can go ahead and sort my usings. And you can find that under edit intelligence as well. And lastly, for the quick fixes and refactoring, I have the ability to now decide where I want to place my usings and actually enforce that as a code style across my entire project. So here I can place my usings inside a namespace and I can configure all of that in my code style. So why don't I go to Ctrl Q and I'll search for code style and it'll pop up all of my C-sharp code styles. Yeah, that I save in my project. Here's where I set my using preferences. Right now it's set to inside a namespace and I'm peering as a suggestion. So now I can get that a little bit more regularly across my whole project. Right, so all of these code fixes and refactorings. Mika, what powers these? Yeah, so all these code fixes and refactorings that you just showed are powered through the Roslin analyzers, also known as the .NET compiler platform analyzers. And what analyzers are, they are a tool that analyze your code and reports diagnostics and errors as you're typing. So if you're in, and this typically manifests in the editor as squiggles. So if you're in Visual Studio and you see squiggles, those are Roslin analyzers running in the background. Wow, yeah, it's pretty cool. It analyzes power everything. Okay, yeah. And if we take a look at my error list over here, you can see that analyzers also come with severities. So there is an error severity, a warning severity, as well as an information severity. There's also a fourth severity called hidden, but it wouldn't show up in your error list because it is hidden. And you can go ahead and configure these severities with an editor config. So next I wanna talk about editor config and code cleanup, but first for those of you who don't know, an editor config is a single file that documents all of your code style options and it lives at the root of your repository and it can be managed by your regular source control and share amongst your entire team. So that's pretty cool. And so here's where my editor config is and this is the analyzer that Kendra just showed. So this is the Usings, Insider, Outside and Namespace analyzer. And let's say my team is like super adamant about having this analyzer, having these namespace, these Usings within the namespace. So I wanna go ahead and bump the severity of that analyzer to a warning instead of having it on silent. So then I will notice if I'm violating that code style option. So going back over here, you can see that I now have these warning squiggles and my error list has been updated with all these warnings. So I can just place my cursor over here and type control dot. And here I can actually move these Using directives to be inside my namespace and those warnings will now disappear. But notice how I have these faded out Using statements and if I hover my mouse over here, Visual Studio is letting me know that these Using directives are unnecessary. So again, I can either type control dot and accept that code fix or better yet you can actually run a code cleanup with this. So you can move these along with other code style violations with our one click code cleanup. So you can pretty much use code cleanup by clicking on this tiny little broom icon or by typing the keyboard shortcut control KE and that will fix all of your code style violations on the current document. Oh, but what if I wanted to apply it to my entire solution? Well, yeah, I thought you would never ask Kendra. So you can simply just right click on the solution name within the solution explorer and you can select Analyze and Code Cleanup and then you can actually run the code cleanup and that will apply those fixers. That was fast. So that applied a subset of all of the fixers that could be applied to my project. Yes, exactly. Gotcha. Okay, so code style, analyzers help imply them through errors and warnings. Okay, cool. And if you take a look at the next warning I have over here, if I hover my mouse over this, Visual Studio is letting me know that I should add a serializable attribute to my class. No. I haven't seen that before. Yeah, so this is actually not built into the IDE but it is actually a NuGet package called Microsoft Code Analysis Ethics Cop Analyzers. And so what our team did was we took the most popular Ethics Cop rules, code quality rules and we ported them into this one NuGet package. And it was a bit too verbose to have within built into Visual Studio so we kind of just created a NuGet package so anyone can just go ahead on NuGet and grab that. So this NuGet package is actually changing what errors and warnings I get in my IDE. So it helps me code. It's not necessarily a library that I'm taking a dependency on. It's something that affects Visual Studio. Yeah, exactly. Yeah, it's really awesome. It just helps you be more productive, write better code. So I love this NuGet package. Sweet. And this package will live under this dependencies node within the solution explorer under this analyzers node and then I can just expand this and these are all the different analyzers or rules and you can simply just right click on one of these and you can actually set the severity of this. Wow. Yeah, but a brand new feature that I am super excited to show off is the ability to configure the severity level of an analyzer within the editor. Show me. Yeah. So here if I type control dot, I can select configure the severity and here let's say I want to bump up the severity level of this analyzer to an error instead of a warning. You can see here that my error list has now been updated. I have a red squiggle. Turned into an angry red squiggle. Yeah. Super angry. And then if I scroll down over here, you can see that it actually just added this rule for me in my editor config and the severity level has been updated to an error instead of a warning. Nice. And if you don't have an editor config, it will go ahead and just generate an editor config for you. So it's pretty awesome. Sweet. It's pretty easy to edit your editor config so, you know. Oh yeah, it's almost too easy at that point. So make sure as you're going through and using this cool new fly out menu to configure your analyzers, know that when you push that editor config to repo, which is one of the great things about editor config that it lives with the rest of your codes, your entire team will have the same one. But that also means keep aware of like merge conflicts and stuff. If everyone's editing one resource of course. Yeah, exactly. Yeah, cool. Yeah, so with great power comes great responsibility so responsible guys. The next thing that I want to talk about, so a lot of people have asked to have the ability to have, you know, third party analyzers to actually break builds, but not necessarily like show up while they're typing. So I want to talk about the code analysis project properties page. Fancy. Very fancy. So I'm going to close these nodes a bit just to clean it up a little, yeah. Yeah, you know. So here I'm going to right click on my project name and I'm going to select properties. And under this code analysis tab, I can actually deselect run on live analysis and you will notice that the error has disappeared. Vanishing act, okay. And not only that, if I go ahead and type control shift B to run my build. It reappeared. Yeah, my build actually failed too. Ta-da, oh my gosh, it failed your build. Yeah, so yeah, so we now have the ability to configure these, you know, to break builds. So it's pretty awesome. So if I don't only want to see certain analyzers when I'm about to check in, so like when I do a build and make sure my build completes, I can, but while I'm actually coding, I don't need all of those sort of, yeah. Exactly. Cool, so I can actually configure that. Exactly. Oh, I like it. Me too. Thanks so much. All right, what was our next off is IntelliCode. IntelliCode, yeah. I'd love to talk a little bit about that. So IntelliCode is Visual Studio's AI model that was trained over 2000.net repositories. Yeah, to basically give you the right hints. So we have dot completion, we have argument completion, we have a few things in preview right now. We've also recently added visual basic to its completion scheme as well as MySQL. And MySQL also has a VS Code extension. So you can still get SQL completion and VS Code. Pretty cool. Okay, so now I went to show and this takes some concentration. So I don't really trust my tests until I see them fail at least once. So I'm gonna go ahead and add some assert fails to these lines. And naturally, as soon as I get to demo it, even though it works fine the first thousand times, hold on, let me see if I can recover. It's really cool, guys. You guys, I've seen this demo, it's amazing. And this feature is in preview. If I get it to show off, it is not gonna show off. Okay, well, let's try it one more time. IntelliCode suggested edits. Please, please, please, please. I didn't make enough sacrifices to the demo gods. Let's see. Okay, if I close out, if I save it, I exit. This is the ritual that we do to please the demo gods. Okay, you actually can see, let's see. Oh, you know, I'm not even getting IntelliCode suggestions in here. So my extension could have crashed. Do, do, do, do, do. Anyway, so now that I have some failing tests, let's go ahead and run these in my test explore. So you might have noticed we have a huge test explore update in 16.2, so it's a lot more customizable. We are focusing entirely on better handling of large test sets. So we have customers with over 200,000 tests. Right, so organization and customizability of everything that's in your display is really, really key. So, test explore, I got a pretty big face lift. Okay, first thing I wanna call out are these filter buttons. So I can easily filter down to only the failed tests or show past tests and not run and all of that. We have easily filter buttons. Next two things are these buttons at the top. So this is repeat last test run and the repeated failed test. So I can go ahead and hit that. So those were keyboard shortcuts that did exist before, but I would get asks for them to add them to the product about once or twice a month, which is pretty frequent. So basically we didn't think people were discovering them, so now they have icons. They are icon worthy, I like it. All right, so the next thing that is pretty cool in this test explore is being able to kind of customize what columns you see. So you guys probably noticed I didn't have my duration column here. So if I'm not doing performance work, I can actually hide my duration column and uncheck that check box and all I need to do is right click in order to display certain columns. Pretty sweet. The more customizability is your group by. So by default, the group by is grouped to a project namespace and then class. This is each tier in the hierarchy that you see. So this is the project namespace and then we go down to the class level. So you can also completely customize this group by. So if I wanted to group by state, notice state has a one beside it and then class, I can do that. And as soon as I click out, boom, it's back to being failed and then a class name. So that is a customized group by. We also have the ability to create these playlists but now they open up in a separate window. So if you really wanted to focus in on the subset of tests, kind of ignore everything else in your test list, just focus in on one thing, it's really easy to do because you have a separate tab to do that. And you can save this just like you normally would as a dot playlist file. But if you don't, if you want it to kind of be an impermanent thing that you build up and then it goes away and you don't have to worry about it, you can just exit out of it and it's not a permanent kind of test list. Along the playlist lines, I actually want to talk a little bit about live unit testing. So live unit testing is an enterprise only feature that run tests automatically in the background as you type but it only runs the tests that were impacted by your code changes. So it kind of runs this subset. So it appears, it gives feedback right in the editor of test that failed. And if I go into my product code, but I go somewhere with a little bit more test coverage, there we go. I can actually see how many tests are covering which lines of code. So yeah, and also it'll give me feedback. I can navigate and run those all from my product code. And as soon as I break something or let's say I retype something, it senses those changes and reruns only the tests that cover that line. So in live unit testing, we also had the ability to include or exclude certain tests. Now we have a live unit testing window that will actually help you keep track of your whole test list that you've included or excluded. I also have little buttons to help filter and all that goodness that you like in the new view. My very last thing I wanted to call out was you may have noticed we are a much easier handling of multi-targeted tests. So not only do I have a target framework column that easily lets me know, hey, if I have a test that's compiling against both Netcore app 2.1 and like Net461, I know which one is which when I look into the test explorer, which was a bit of an effort before. I can now easily see that and I can even group by my certain target framework. So if I wanted to easily kind of delve into bugs that I was experiencing on a certain platform, I can. All right, let's see. Do we have time for preview features? I think we do. They've been good. They've been such a nice listeners. Great audience, yeah. All right, let's jump into it. So preview features, this came out today, right? Today, yes. Yes, we successfully shipped 16.3. Awesome, so the first 16.4 preview won. Yes, okay. So the first feature I wanna show is go to base. Go to base allows you to navigate up the inheritance chain. So you can right click on here and now go to base is a right click context menu option or you can use alt home which is the keyboard shortcut and there you go. Now I just jump to my I tweet alert interface and this also works for method override. So here if I place my cursor and type alt home in this method it will open this window and I can just jump to either method that I have overridden. So that's pretty, pretty sweet. Okay, and the next feature I wanna show is it's actually an analyzer that was built by one of our very own interns this past summer. Yes, and it's add null checks for all parameters. So here if I place my cursor and type control dot it will actually and select add null checks for all parameters will actually add all these if statements that checks the nullity of all these you know, nullable non-checked parameters. So I don't have to go one by one anymore. Exactly. It was a new mall one. Visual Studio, let's do that for you. I like it. It saves you a ton of time. And then you might have noticed all of these XML comments. So we now have code cells for these. If I hover over the I tweet alert interface you can see that quick info will show me italics as well as bolding, bullets, and a clickable link. A clickable link, clickable link. Finally, you can link directly to more documentation from your code. Oh my gosh, that's awesome. And if you add this inherit doc tag over here my tweet alert class will actually inherit the XML comments from my I tweet alert interface and it works for method override. So here I have a method that says this method is something and then if I hover over this method it'll actually show that inherited XML comments. So it worked for both the class that inherited the interface as well as the overridden method. Yes, exactly. Nice. Pretty sweet. Sweet. Let's see. Do we have resources to share at the end? Yes, so we do. Okay, there's resources. So if you wanna file bugs on our team or on all Visual Studio go to developer community.visualstudio.com. If you wanna check out more all of the refactorings that we just packed into this please visit aka.ms slash refactor. It'll take you right to our docs. And yeah, so our team, me, can I work on the .NET tooling team or Roslin, which is our compiler. So go to aka.ms slash Roslin to engage with our team and file bugs or contribute. Yeah.