>> On today's Visual Studio Toolbox,
Mads Christensen returns to show us some of
his favorite features in Visual Studio 2019.
Should we make this a longer, or shorter episode?
[MUSIC].
>> Hi. Welcome to Visual Studio Toolbox.
I'm your host Robert Green and joining me
today is Mads Christensen.
Mads, Welcome back.
>> Thank you very much.
>> It's been a long time.
>> Yes.
>> Way too long since you've been on the show.
>> I agree. It's good to be back.
>> We're here to talk about Visual Studio 2019,
which has just recently shipped.
Had a great launch, a lot of great content from the launch event,
we'll have pointers to that.
But I thought what we would do, is a couple of things.
One, is just have you
come on in and show us some of your favorite features,
to keep the excitement going,
and then two we're going to try and experiment.
We talked a lot about how long these shows should be?
And when do people stop watching?
And I tend to go longer
than people want because I tend to talk a lot.
So we're going to try and experiment today.
I'm going to do less talking,
and we're going to focus more on demos,
and we're going to see what
happens if we keep this a shorter episode,
and then you guys are going to tell us whether or not you like it.
>> So I basically have 15 minutes.
>> Fifteen minutes.
>> To show as many of my favorite features as I can.
>> Yes, starting right now.
>> All right so in Visual Studio 2019,
I want to start with the new search experience.
So we completely redid how we do Visual Studio Search. I love it.
So as I type,
you see how I get search results.
I get that globally from around Visual Studio,
all the commands, menus,
components, templates, all sorts of things, including options.
So let me just start by going in here
and make the font
a little larger in the editor when we get to that.
I can also say new console app,
that gives me the console app template.
I'm just going to say okay, to create that.
That was it, I now have a new console app.
>> Wow.
>> That was fast, right?
>> So that's even faster than calling up
the new dialogue and searching in that.
>> It is.
>> Geez.
>> Yes, that's why it's one of my favorite features.
It makes me more productive.
So let's start coding here.
So this is just the default static void main method I have here.
Let's see if we can do something a little different.
So let's create a string array.
I'm going to create a new array of strings, okay?
I'm going to put two strings in there.
I basically want "Hello world" to be in an array.
So I'm going to copy hello,
Control C to copy,
and I'm going to go straight on and Control C again on world.
So now I've copied both.
So now, I want to hit Control Shift V to insert.
Not Control V to paste but Control Shift V,
and that gives me the clipboard ring
which is now visualized so I can choose,
which of the things I've copied,
and insert them super easily like this.
>> Nice. So if you do a Control V,
will it insert in order?
>> Yes. So Control V is just a normal paste.
>> All right.
>> But Control Shift V which has been there for a long time.
>> Control V has been there for a long time.
>> Control Shift V has been there for along time too.
>> Okay.
>> But as the new thing, it visualize.
You can see what's in the clipboard ring is what it's called.
>> So Control C, Control C has
always stored multiple things to the clipboard?
>> Yeah.
>> Cool.
>> Yeah. So moving on,
let's say that I want to print out,
I want to concatenate these two hello and world.
I want to concatenate them into one string
and that I want to write out to the console.
But only, and this is a contrived example.
But I want to make an if statement here.
If my list.length is larger than zero,
then I want to print out.
So I'm just going to hit dot and look at
all these new things I've got here.
Refactoring. So we got a bunch of
new refactoring that makes it super easy to do
all sorts of more advanced things and
I'm actually just going to add braces to this one like this.
So that's been there for awhile.
But it's really helpful to have
all these new refactorings that make me make it easier
to convert code from one thing to the other.
Going back from link queries to foreach loops and vice versa.
>> Cool.
>> Really really helpful. So now I can simply just go down here,
and do a string join.
I'm going to join on an empty string,
and I'm going to provide a list.
Now see what happened here.
I'm going to just force this again.
So I'm going to zoom in.
Notice how the first two items, list and args.
Arg has a star because IntelliCode,
which is a new feature in Visual Studio,
it's an optional extension at
the moment so you have to install them.
But it knows the context I'm in.
It knows that this particular method, the string join method,
takes an array of strings and then it knows that,
"Oh, I actually have two that are in scope."
I have args up here and I have list right here.
So it suggests to me those at the top of the completion list.
So that's just super helpful,
and I can easily insert like that.
>> Cool.
>> So IntelliCode is really a fantastic aid especially
when you're dealing with new APIs
that you're not so familiar with.
It helps you to figure out
what is the most common use patterns of different API.
>> IntelliCode is basically
IntelliSense with bunch of AI behind it.
>> Yeah.
>> Getting very smart about it.
>> We've been scanning like thousands of
GitHub repos for the different languages,
for C# for instance, to
figure out how people used various different APIs.
Based on that, we put it into a machine learning model and
outcomes a very very clever IntelliSense engine.
>> Cool.
>> Well, that sits on top of the current IntelliSense.
So that's very nice and I forgot a parenthesis here. All right.
So let's set a break point.
So now it runs and it breaks and I can see down here in
my Local's window that I have
my list member here and I can now search.
So I can now search for world and notice
how it can find values that are in lists or dictionaries,
whatever, no matter how deep they are in the hierarchy.
So that's really welcomed and that works in Autos,
Locals and the Watch windows.
So it makes it very easy to find these hard to find
some time values of properties and so on.
>> Cool.
>> So I'm just going to continue here, F5.
We can see the hello world is printed out but notice,
it didn't close down when it was done,
it keeps going, and there it goes. That's very nice.
So that was some of the new things.
So what you probably couldn't
tell was that the step debugging was a lot faster.
So as I was setting the break point and it was hitting,
that's over 50 percent faster now than it used to be.
>> Okay.
>> That's a very very nice thing.
>> Yeah, it's hard to tell in a simple console app like this.
>> Yeah, right. All right.
So let's make a mistake here.
So I'm removing a parenthesis here so I now have a syntax error.
So at the bottom of the window,
I now have what's called the document health indicator.
So it tells me without having the arrow list open,
I can now see that, "Oh, I actually have one error.
I don't have any warnings." But that
makes it super easy for me to see that,
"It's not greened, this file actually have some issues.".
>> Right.
>> Typically, that's because you
scroll your syntax errors out of you,
and so you don't necessarily
know when you're trying to build for instance.
So glancing at this makes it super convenient to see.
So I can navigate between these errors,
Alt Page Up and Page Down.
So that takes me exactly to where they are,
and I can fix them to recently and
now no issues found we're good to go.
>> Cool. So that's in addition to
the showing it on the scroll bar as well, right?
>> Well, yes and it gives you the navigation so you can
very easily go between the errors and see what's going on.
>> So I want to show another thing here.
So let's just save this.
Let's add this to source control.
>> Let's do that.
>> So I'm going to right-click this solution
and I'm going to Add Solution to
Source Control and it's going to add it to Git, and here we go.
Now it's all first commit. Now, let's make a change.
This change I want to do is I want to clean
up this file a little bit.
So I want to remove all the comments.
You can see there are other things here
like I have unused using statements and so on.
Let's produce some formatting issues
here like I have some wrong indentation here.
So I have an extension called comment remover,
that lets me very easily just remove
comments with a keyboard shortcut, like that.
Now, I want to do the code cleanup.
So as a new feature down here at the bottom,
let's zoom in here a little bit,
we can see that we have
a couple of profiles for code clean up that we can run,
one of them has a keyboard shortcut assigned to it,
and we can configure those two profiles in here.
So I can figure them to have a bunch of code fixers.
Now, these code fixers I can remove them out
or back into what the profile will run.
These includes like "sort usings" or "remove
unnecessary usings." A bunch of things.
So now if I hit "Ctrl KE",
that was the keyboard shortcut, we
can see here how my code is just tightened up.
If I were to do a code review,
I'm in a much better place right now because now we don't
have to talk about formatting
and coding style convention and so on.
>> How do you create those?
>> You go down here to
the bottom and open the menu and click "Configure Code Cleanup."
>> So how do you find additional fixers to add?
>> So right now the only fixers
are the ones that are build-in there, 14 build-in.
>> Okay.
>> So in the future, we will see this change.
>> Okay.
>> But as of right now we have this 14 build-in.
>> Got it. Okay.
>> They're super helpful. So now
I have a change, I'm going to save the file.
I'm going to commit,
it but I'm not going to fully commit this.
I'm going to call this cleanup.
Instead, I'm going to stash it.
So I'm just going to stash. So what
happens is I don't create another branch,
I basically create a stash where I'd
take the changes that I have and put them away locally.
If you see what happened is that my changes in the source
here was reverted because I took the changes and stashed them.
So if you're used to TFS,
for instance, you have a shell set.
>> Right.
>> The difference is that shell set
actually exists on the remote server,
whereas a git stash only exists locally.
So only on my machine here.
>> Okay.
>> But I have it right down here,
I can apply it anytime I want.
Typically, use cases for this is I make a change,
but then I have to fix a bug
really quick and I have to change branches.
So I can stash my stuff,
change my branch, and then come
back afterwards to that branch and apply it again.
Or I can work in one branch,
figure it out, "Oh man, I should have done it in another branch.
Stash my change, change to that other branch,
and apply it to that branch."
>> Branch?
>> Yes. So that's super helpful
that I can do it all the way right here.
All right. Let me show you another really cool thing.
This is the last thing I want to show.
>> Okay.
>> So let's close this solution. I'm going to
open a bigger solution that's got a bunch of projects.
>> Pro Power Tools. My all-time favorite.
>> Pro Power Tools. Actually, I want
to do something a little bit different.
I want to open it in a different way.
>> We had the very first Visual Studio toolbox episodes
about Productivity Power Tools.
We split into two episodes because we had to keep it short.
>> So now I want to open a solution that's on my desk here.
There's now a new option down here.
So say "Don't load the projects."
All right. That's kind of bizarre until you see what's going on.
This is a solution that has many projects.
There are solutions out there that are way bigger,
but you saw how fast this was loaded.
>> Yes.
>> So a typical scenario is that,
if you have a solution with a lot of projects,
you might only work on a subset of those projects.
So it could be like you have a backend and
then you have like a Windows,
desktop front end and ASP.NET front end.
But you only work on either the ASP.NET front
end or any of these other things,
so why even load the rest?
So now nothing is loaded.
I can go in and say "I want to load this particular project."
So just like normal, I can say "Reload project."
But now I can also go in here and say "Load Project Dependencies."
Okay. I have this particular project has other dependencies on
other projects in the solution that it needs in order to build.
So now I can do that. In this case,
it was just this other [inaudible] up here.
>> Cool.
>> So now these are the only two projects loaded,
and I can hide everything else or show it again up here.
>> Is there a way to basically set the equivalent of a profile,
where some days I want to load these three projects,
other times I want to load a different three projects?
>> Yes. I'm glad you asked.
So now that I have my definition here,
these are the two projects I want the solution that I care about.
I can right-click and say "Save As Solution Filter."
>> I love that. This was not scripted.
Ladies and gentlemen, I actually was just
thinking that would be a cool thing to
have. It's already in there.
>> It was a perfect segue.
>> Cool.
>> So this saves a file.
So I'm going to call this one since
you know that the project names are column guide.
So I'm just going to call it Column Guide,
and if we look here, it's going to save as an slnf file.
So solution filter is the f.
>> Cool.
>> So save that. Now, let's just close this solution.
Now I have the slnf, I open it.
Boom, it only loads this.
So that slnf file roams in my repo.
So other members of my team can also use this.
You can create as many as you want.
So it can be one for the ASP.NET team,
one for the desktop team, one for the back-end team and so on.
>> Excellent.
>> So that's very helpful.
So one question that we get with this is,
well, what if you make changes to the solution file?
Let's say you add new solution items.
In here for instance, what if I add a new file here?
Well, how does that then roam between those different filters?
Well, the good news is that the filters are actually
just a small little JSON file
describing just a project that it has to load,
but it still uses the original sln file
to figure out what is there.
So when you make changes to the actual solution,
everyone gets the benefit regardless of
what filter they have applied.
>> Right. Because it is just a filter of what's project is open.
>> Yeah, exactly.
>> Cool.
>> So if you have a big solution then this is going
to speed up your, I work day a lot.
>> That's excellent.
>> Yeah.
>> Cool.
>> Those were my favorite features and there's a bunch more.
But these are my favorites.
>> That was one minute me
talking and 15 minutes of demo. We did it.
>> Yes.
>> I actually like this a lot.
I think we should do more of these.
But as always, you guys let us know
if you liked the 15 minutes or if you
wanted us to spend more time diving down.
So as always this show is all about you.
So let us know what you think.
Hope you like that and we will see you next
time on Visual Studio Toolbox.
[MUSIC]