>> Hello and welcome. I'm Aaron,
and I'm a Product Manager for
IntelliCode suite of features in Visual Studio.
Today we're going to look at our suggestions feature set,
specifically suggestions for repeated edits,
to help you do your refactorings as suggestions for quick actions,
which will help you do
your routine and quick actions in your code.
Let's start with repeated edits.
Here we are in a solar system CodeBase.
We've got a program that helps
calculate distances within the solar system.
We're given our base units in kilometers,
and we're going to return some distances in astronomical units,
and in light years.
We can see here in the base code,
the calculations are in the return statement,
and it looks quite messy.
What I've gone ahead and done is write
some functions to do the conversion for me.
We're going to go ahead and start doing
our refactorings for our conversions into light years.
I'm going to start here by making my first edit,
kilometers to light years,
that's the first repeated edit.
I'm going to do my second repeated edit here.
That's my second repeated edit.
We can see here that IntelliCode has detected
the repeated edit and
the other locations where I might want to do this.
There's two ways to use this feature.
You can either use the screwdriver here with your cursor,
or by hitting "Control + Period".
Here we see that we can apply the repeated edit suggestion to
just this example or the remaining examples inside this file.
There's another way that we can use this feature,
and this method is entirely in your flow.
If I just type in kilometers to light years,
we see that the suggestion
actually appears in my completions list.
You don't have to go looking.
If IntelliCode suggestions has detected this repeated edit,
we will actually put it in your flow,
in your completions list,
and you can do this all by typing.
I want you to notice here that there's actually a key
binding to go to the next instance of this suggestion as well.
I'm going to hit "Enter" here, and that's applied it.
We've got one example left,
and we can do this either using
the key binding or in the "Tool" window below.
I'm going to use the key binding,
"Control + Alt + Comma",
and you can see here that we've actually suggested
this repeated edit in your code.
I'm going to hit "Control + Alt + Period".
Cool. This is repeated edit suggestions after two examples.
But in some cases,
we can actually do this after one example.
I'm going to go into
the refactorings for kilometers to astronomical units.
Here, again, kilometers to astronomical units.
This is my first one.
I'm going to "Control", hit "Comma".
I'm going to go to my next example here,
and I'm going to hit "Control + Alt + Period".
You can see here, because I am
specifically asking for the change
to be made with "Control + Alt + Period",
it has gone ahead and applied this for me.
Again, we've got two instances left,
and we can again use similar method to apply this.
I'm going to use the light bulb this time
to apply all the other suggestions.
As you can imagine,
if you've got many similar edits to do in a given file,
IntelliCode suggestions can really help
you save some time by finding
the remaining locations and doing the edits for you,
no matter how complex they can be.
In some instances, we can save tens of minutes,
or even hours,
depending on the complexity and the frequency of the edit.
Switching gears a bit,
we're going to look at IntelliCode suggestions for quick actions.
I've got a class here of planets that I'm
going to start authoring so let's begin.
We want to keep track of some properties like
the diameter of a planet and the composition of a planet.
I'm going to begin writing my constructor.
Because I've just written some properties,
and now I'm going to write a constructor with the properties,
IntelliCode has detected that I'm intending to do this,
and based on the detected intent,
it's going to suggest that I generate the constructor.
Look at this, by writing the properties
and starting writing my constructor,
IntelliCode can now suggest,
I could complete this constructor for you.
This is the first of
two quick actions that we support generating a constructor.
This is another example of IntelliCode writing
the routine code edits for you so
you can stay focused on the code that matters.
I'm going to hit "Enter".
Look at that, it's generated the constructor for me.
Now, what if I've forgotten
a property and I want to add a property to this constructor now?
I'm going to start writing a property to
keep track of the distance from the sun.
I'm going to cursor into
the constructor that we've just generated,
and I'm going to begin double distance from sun.
Look at this, again, in your flow,
in your completions list,
we can help you complete this code edit.
I'm going to hit "Enter" to accept,
and I'm going to show you one more example.
Now, what if we have a planet that doesn't have moons?
Not every planet has moons, and that's okay.
We love those planets too.
I'm going to start typing int,
and we can see again,
the suggestion shows up.
But wait, we can
add the optional parameter into your constructor for you.
I'm going to hit "Enter" here to accept.
What have we just seen?
We've seen IntelliCode detect that by adding
properties and starting to write my constructor.
In my completion status,
I have the option to let IntelliCode suggest the quick action
and complete the code change for me by generating my constructor.
We've also seen the second quick action that we can suggest,
which is by adding the property to the class,
and then cursoring into my constructor,
IntelliCode can suggest adding
that parameter to the constructor for me,
whether it's mandatory or optional.
In short, between suggestions for repeated edits,
suggestions for quick actions,
IntelliCode can help you
make the changes that you're intending to make,
and help you stay focused on the work that matters.
Thank you for joining me today.