Showing posts with label Toolbox. Show all posts
Showing posts with label Toolbox. Show all posts

Wednesday, February 4, 2026

Creating Games with Unity and Visual Studio

>> You know Visual Studio Toolbox,
it's all fun and games.
We always have fun.
Today, we're going to
see with Visual Studio in Unity.
That you can build
games like this.
Hi, welcome to Visual Studio
Toolbox. I'm your host
Robert Greene, and
joining me today is
Arturo Núñez. Hey Arturo.
>> Hey Robert, how are you?
>> Good. Arturo works with Unity,
and so we're going to talk today
a little bit about gaming.
>> Yes.
>> Unity and Visual Studio have
gotten along very well
together for quite some time.
It only gets better.
>> Yeah.
>> So, you're going
to show us some of
the new things in the latest
version in Unity,
latest version Visual Studio,
you're going to turn me
into a game writer in
less than 20 minutes. This
is going to be awesome.
>> Possible, yeah.
>> Cool.
>> Yeah.
>> So, let me talk to
you about Unity first.
>> Okay.
>> So, of the audience who
doesn't know what Unity is.
Unity, it started
as a game engine.
But now, we call it
a creation engine.
Basically, you can
create games but you can
also create interactive
applications for VR,
AR in 3D, 2D.
>> Right.
>> So, that's what we are doing.
>> So, if you do
HoloLens, there's Unity.
If you do mixed reality
there's Unity.
>> Right. So, we support
30 plus platforms.
So, basically, if you want to
deploy your project to
any platform that's out there,
you can with Unity.
>> Yeah.
>> Cool.
>> Yeah. So, the tool
is pretty easy to use.
So, if you're an artist,
you can grab Unity,
you can create something cool
without having to program.
If you're a programmer, you have
complete control over
what you want to do.
Like, if you want to
program the graphics,
you can do that.
If you want to program
the behavior of
your characters or the
things that's there,
you can absolutely
do that using C#.
>> Right.
>> As a language we support.
>> So, you create the graphics,
the UI if you will in Unity.
>> Yeah.
>> Which has its own IDE,
and then in Visual Studio,
you do the scripting.
>> Right.
>> You can do in C#
and other languages
to actually control what happens.
>> Right. So, Unity takes care of
everything like the rendering,
the audio, all of
those things for you.
So, you just need to focus
on the behavior specific
for your project.
>> Okay.
>> That's how it works.
It's C#, we support
other languages
but the best experience
is, it's using C#.
>> Right.
>> Yeah, that's what Unity is.
Yeah. So, let me show you.
>> All right.
>> A demo using Unity.
So, this example is
called AngryBots,
something like six years ago,
at the same demo, now with
the new newest features of Unity,
we're showing the same project
but with a newest
graphics addition.
>> Okay,.
>> This is how Unity works.
It's an editor, it's software,
so you can basically drag
and drop stuff into your project.
So, in this case, I created
these spider robot
in another program.
These are 3D models, the textures
were made in another program.
I bring those into Unity,
and I simply can position them
whenever, whatever I want.
>> So, you need to have this
type of graphics capability?
I need to be able to
draw floors and robots?
>> That's a good question.
Usually, you can you if
you have the ability
to make them.
However, we have something
called the Asset Store.
>> Okay.
>> So basically, if you
just want to focus on
the coding part,
you can go there,
grab some stuff
that it's premade,
some animations are premade,
and just use them
for your project.
>> Right, and then you can
edit those if you want to?
>> Yeah, absolutely.
>> Okay.
>> If you like this spider
but you want another color.
>> Right.
>> Or are you trying to
make some more changes,.
>> More legs or fewer legs.
>> Right, that's possible.
>> Okay.
>> So, that's how
you create your-
>> Okay.
>> - world. You can have
a 2D or 3D project
and the only thing you
have to do is simply,
click "Play" to start
the simulation of
your project and you can
start playing right away.
>> Okay.
>> So, Unity also takes
care of all the input.
So, if you're playing
on a PC or an Xbox One,
or whatever Unity will
translate that input
into whatever you
were working on.
So, it's a really simple game,
a shooter, that space marine.
We have a lot of tools inside
Unity to create these things.
However, the powerful thing
here is that you,
as a programmer,
can add behavior on
top of everything that
Unity offers you,
either on the runtime
or on the editor.
Unity is fully extensible.
So, if there is something
that Unity doesn't
have right now,
you could go there and
extend the Unity Editor.
So, yeah that's in
a nutshell what Unity is.
>> So, the creatures that
bought the space marine
that comes with
some built-in behaviors,
like the ability to go
forwards and backwards,
and left and right
and jump, et cetera?
>> Yeah.
>> Then, you program
additional stuff?
>> Right. So, some
of these objects already
come with built-in behavior.
>> Okay.
>> So, if you want to start
prototyping or doing
some of those things,
we offer you a collection of
assets that you can
simply drag and drop,
and start having something
like a camera that moves around.
>> Okay.
>> Or a character
that walks around.
But as you progress
during your development,
maybe you want to
code the specifics
for that project you want.
>> Okay.
>> That's where.
>> Because I think that if
you're just starting out,
you'd want to reuse stuff
that's already made.
>> Yeah.
>> You get the feel
for how it works.
>> Yes.
>> Then, get better and
better in terms of creating
your own assets, et cetera.
>> Right. So, yeah.
That's the idea that used to get,
started using Unity real quick.
But if you are an advanced user,
you can do whatever you want.
>> Okay.
>> Yeah, that's it.
So, this is the editor of Unity
and the best idea ID for
editing your C# code,
and I'm saying these
truly, it's Visual Studio.
>> Yeah.
>> I've been using
Visual Studio for forever.
Every time, we are working
closely with Microsoft,
so the experience gets
better and better.
>> All right.
>> So, now, we have
the ability to
debug your Unity projects
in Visual Studio
and the workflow,
it's so clean, it's so fast.
That's one of the things
that I'm super excited.
>> Cool.
>> So, yeah. This is a
basic C# script for Unity.
Basically, if you want to respond
to Unity's built-in messages,
you need to extend
MonoBehavior class.
>> Okay.
>> But you already know C#,
I will say, you are
like on the other side.
>> Right.
>> You already know most of
the things you need
to do to start.
>> So, it brings up
an interesting question.
Unity is on the Mono runtime.
>> Yes.
>> Right? So, what version of C#,
what version or equivalent
version of .NET if
I come in here?
>> Yeah.
>> How much of what I'm used to,
would I be able to
actually run inside here?
>> Right. So, we're
revamping that.
A couple of years
ago, we were still
using old versions
of C# and Mono.
Right now, we offer support
for the equivalent of 4.2.
>> Okay.
>> 4.X runtime.
C#, currently we support C# 6.
>> Okay.
>> But with the newest
version of Unity,
we're going to
support C# 7 feature.
>> Okay,.
>> So, we're trying to get there
to provide the latest tools
that are out there.
>> Right.
>> Yeah.
>> Then, that gives
you the ability not
only to do basic C#,
but call into
various frameworks stuff,
talk to Azure if you want to
store information up on
the cloud or whatever.
>> Yeah.
>> Because it's.NET.
>> Yeah.
>> Right.
>> Absolutely.
>> Cool.
>> So, yeah. That's something
that you can absolutely do.
Also on the performance side,
now with these upgrades
of the runtimes,
recurring performance boosts,
also some bugs have
been fixed now.
>> Yeah.
>> So, it's pretty.
>> Okay.
>> Yeah. So, yeah,
I just want to show you.
>> Yeah.
>> A couple of things of
how the workflow works.
If you are using
Visual Studio and
Unity, so for instance,
as you have seen here,
Unity comes with
a project window.
>> Right.
>> So, this part of window
has all the assets
in your project.
So, from textures, sounds,
scripts, videos, everything.
If you're a programmer,
you might not
necessarily care
about these assets.
You just want the code,
you just want to have
the scripts somewhere at hand.
So, with Visual Studio,
if you go to "View" window,
there is a new "Unity
Project Explorer",
and this tool allows you just
to see the scripts
in your project.
>> Okay.
>> So, if I'm just focusing
on programming right now,
I don't need to worry about
clicking other assets
that I don't care about.
Another cool thing, and this is
if you know already C# but
you don't necessarily know
the specifics of the Unity API.
>> Right.
>> You can go to the documentation,
do things like that.
But if you just want to to
get up to speed with this,
there's an awesome feature.
>> Then, I see the screwdriver.
There, you see your full
support for Roslyn.
>> Yeah. So, yeah.
>> Or at least, much support.
>> Yeah. So, yeah.
>> All right.
>> So, there's an option if
you click "Ctrl+Shift+M",
the Implement Unity
Messages option appears.
So, all the messages
you can see here
are messages that
any MonoBehavior
can be seen from the engine.
So, every time you click "Play",
Unity calls start on
all the objects that
are on the scene.
So yeah, sometimes, we
have a lot of them.
>>Yeah.
>> So, maybe you don't
know all of them,
this feature, it's pretty useful.
So, in case I want to say,
"I'm pleased Visual Studio."
Define sorry- The "On Trigger"
enter message, right?
If I want to listen to
whenever two objects
collide with each other,
then Unity is going to notify me.
Okay, something collided here.
I didn't have to go to
a browser to search
how it's their correct signature
for this method,
so it's pretty quick.
I also want to show you
how easy it is to debug.
This is very important because in
the previous IDE Unity used
or what's it shipping with;
it was hard to do the bombing.
So, developers ended up just
printing everything
to the console.
It's difficult to do that.
That's not the best tool to that.
Within Visual Studio, you can
simply add your breakpoints,
as you do if you already know
how to use Visual Studio.
In this case, this
breakpoint will be called
every time I shoot a projectile.
>> Okay.
>> Within Unity, I can simply
"Attach to Unity and Play".
So, I don't need to be switching
between Unity and Visual Studio
so I can simply say,
Visual Studio, launch Unity,
while you connect
to that process.
So, I can now start
debugging my project here.
So, as soon as I shoot,
Visual Studio
captures that event,
and I can inspect as you
already do in Visual Studio.
>> Very cool.
>> Yeah, it's pretty cool
tools for developers.
Also important because Unity
is now used by
the other industries.
People making interactive
applications, so yeah,
most people are new to
programming so having
these tools at hand,
Visual studio is very
important for us.
>> So, new to programming.
What if you've been doing
.NET for a while, C#,
web apps, line of business apps,
and now you want to
try it here at gaming?
>> Yes.
>> So, the part where you write
C# code in Visual Studio
is pretty familiar.
You can go to
the asset store and get
a bunch of assets, but
how hard is it for somebody
that's just used to
writing regular line of
business apps to come over and
learn the world of gaming and-
>> Right, and the graphics
and things like that.
>> -and graphics?
>> Yeah. So, there are a lot of
resources on the web
on how to learn
using Unity either by
the community but we also
have official documentation.
I think it's fun
to work on these,
because if you are trying
to follow a tutorial,
you're making a game, right?
>> Right.
>> So, you get excited
about shooting a star,
about collecting points
and things like that.
So, there's a lot of
documentation on that.
One thing I always recommend
people on doing is at
least knowing the basics
of graphics or math.
It's not required, but I
think you can have
more fun if you do.
>> Right. Yeah. Well, you have
to understand
the underlying platform.
Like if you say alarms,
use Xamarin and
write mobile apps,
because Xamarin is just C#.
>> Right.
>> You get over there and
the code you write is similar,
but if you don't
really understand
the iOS runtime or
the Android runtime,
how great an app can you write?
If you come over
into Unity and you
know C# and you know
a few things we don't
really understand what
that engine is doing,
how great a game can you write?
So, you do ultimately
need to get pretty good
at that kind of stuff.
>> Yeah, absolutely.
Another thing that is-
>> But you don't want
to have to wait to
master that before you can
create your first game
where somebody runs
backwards and forwards
and jumps, right?
>> Yeah. So, yeah,
definitely you do need to know
the underlying platform
you're running,
the hardware you're
running because
you're writing a mobile game.
But it's too process intensive,
it's going to drain the battery
in a couple of minutes, right?
So, you don't want
that experience for your user.
One thing that Unity
already takes care of is
trying to write
the optimized code
for each platform
towards port two.
However, you still need to know,
as you said, the underlying
platform you're targeting.
>> So, how does that part work?
You want this game to
run on PCs, on Macs,
on various phones, obviously
the code behind is the same-
>> Yes.
>> -any has the ability to
compile into those platforms,
but you have to do
the UI differently?
>> That's an interesting
question. You don't.
We provide you tools,
you define your UI,
for instance, in a certain way,
and then Unity will
take care of scaling,
and managing all those things.
As you said the code that
you write is the same,
Unity will take care of compiling
to the specific platform.
The only thing you
need to do basically
most of the time is
just tell Unity;
Okay, I want you to build
two Xbox One, for instance.
>> Okay.
>> In this case, I don't
have the component loaded.
I need to go to the Internet
and install it, okay?
>> Okay.
>> But it's super
simple to do that.
>> Okay. Cool. Then you
may decide that your game is too
busy for smaller form factor-
Yeah.
>> -and then you might
have to adjust it that
way if the scaling doesn't
take care of it for you.
>> Yeah. Another thing is given
the hardware differences between
devices like if I'm burning here,
I might not care about
my computer draining the battery
because I can plug in,
but if I'm on
the cell phone, I am. So-
>> Sure.
>> -yeah, you need to take
care of those things.
There are a lot of
other components that
you can understand if you want,
if you're interested into that,
but some of the other things
you don't have to.
You just want to have
a lighting source,
you put a light
there, it will work,
and you don't have to worry
about that. So, yeah.
>> Cool.
>> So, you can grab Unity for
free, if you're starting.
There is a personal edition
if you want to try it out.
Everything is unlocked, meaning
that you can do whatever,
that engine is not locked
with any features for
pro customers or anything
so that you can just
play around with that.
Also, I know the audience
it's interested
in like open source platforms,
or open source projects.
Unity itself is not open source.
However, we are opening
many of Unity's components.
So, the UI is open source,
the networking is open source,
many of Uniti's components
are open source.
>> Cool.
>> You can collaborate, you can
receive what's
underlying the platform.
>> Right.
>> That's possible.
>> If you wanted to you could use
Visual Studio Code to do
the scripting as well, obviously?
>> Yeah, you could.
>> You just don't get
the nice tie in from IDE to IDE.
>> Right. So, yeah. Those
are our C# scripts, so-
>> Right.
>> -you can edit them anywhere.
>> Okay, cool.
>> But If you want to have
all the speed of development.
>> Right.
>> That's it. Unity is
available on Mac for-
>> Okay.
>> -for authoring. So, if you
have Visual Studio on the Mac,
the experience is
going to be the same.
>> Okay. So,
Visual Studio for Mac
also ties in just as nice.
>> Yeah, it works great.
So, it's important because
before if you were
developing on PC and then
you had to switch to
Mac to do iOS development
or something,
you had to switch
your environment,
but now you can have
the same stuff running
on both platforms.
>> Awesome.
>> Yeah. So, also we're
announcing this partnership
with Unity and Visual Studio.
There's going to be
a bundle out there,
so you can save a couple of
$100 if you get Unity
and Visual Studio.
>> Okay. So, if you already have
Visual Studio you can just get
Unity user for free
and then at some point
you have to pay,
probably if you're now
selling games and whatnot,
I would imagine, right?
>> Yeah. Well, so, our licensing
it's pretty good I think.
You don't have to pay
us anything if you make
less than $100,000 per year.
>> Oh, okay.
>> You can even make money
out of your projects,
you don't have to pay after
you passed that amount,
you have to-
>> We get to the point where I'm
making six figures on a game,
I'm probably pretty happy to pay.
>> Yeah.
>> I think it's fair.
>> Yeah, correct.
>> No danger of that
happening any time soon.
>> Yeah, we don't
charge royalties.
>> Okay.
>> So, if you become
a super millionaire out
of Unity of your game,
you just pay your license-
>> Okay.
>> -and you don't have to
pay us every now and then.
>> Okay.
>> I think it's important.
>> And then the bundle
is the ability to buy
Visual Studio and Unity?
>> Yes.
>> Okay.
>> That's the bundle.
That's what you save.
>> Cool. All right.
So we'll have links to
that in the show notes.
We'll put some links to
some tutorials and
some getting started.
Earlier today, you did
some getting started videos
is really good stuff
on the Unity website,
for how you might get
started doing this.
Like anything, start small.
>> Right.
>> Do something simple and
then learn bit by bit.
But there's a lot of fun and-
>> It is. It is a lot of fun.
>> It can be a nice change
of pace from writing,
the same old desktop
and web apps.
>> Yeah, definitely.
It's a fun world.
>> Cool.
>> Yeah.
>> Thanks for coming
and showing that to us.
>> Thank you very much.
>> All right. Hope enjoyed that,
and we will see you next time
on Visual Studio Toolbox.

Debugging Tips and Tricks Part 2

>> On today's Toolbox,
we're going to continue
fixing the app we started
working on last week,
and Leslie will show us additional
tips and tricks for debugging.
Hi, welcome to Visual Studio Toolbox.
I'm your host Robert Greene,
and joining me today for part two of
our debugger tips and tricks
is Leslie Richardson.
>> Hey there.
>> Hi, Leslie.
>> Hi.
>> Welcome back.
>> Thank you.
>> You haven't changed a bit since
we recorded the last episode.
>> I know. It was almost like it
like happened five minutes ago.
>> Almost.
>> Yeah.
>> So refresh our memories,
what did we see in part one.
>> Yeah. So in part one, we talked
about a lot of different things,
from Run To Click, set
to .NET statement,
Text Visualizers, DebuggerDisplay
which is my personal favorite,
and of course,
conditional breakpoints,
tracepoints and the list goes on.
>> Cool. So what are
we going to see today?
>> So today we're going to see
a lot of different things,
including some of
the new 2019 features like
Search for the Watch window,
manage data breakpoints.
>> Okay.
>> Then other little things peppered
throughout in the Watch window
such as return value,
keywords, and format specifiers.
>> All right. Cool.
>> It goes on.
>> All right. We're
using the same app.
>> Yeah.
>> Which in spite of
the fact that we've
spent all last week fixing it,
still isn't 100 percent correct.
>> Yeah. Still many, many problems.
>> We like to mimic
the real-world in this show.
>> Fair enough. Yeah. So again,
as a refresher, this is
the same app as in part one,
but it's an app that
will randomly give me
a list of books that I can choose
to read and add to my shelf,
or I can choose not to read it and
it won't be added to my shelf.
So there's several more bugs
that we didn't
fix last week or throughout
the week either,
so they're still here.
So let's investigate those.
So I'm going to add a book,
in this case, this book called
Middlemarch to my shelf.
When I click on it, one of
the problems I have been
experiencing revolves
around this String
here that says that I've
read the book one time.
>> Already. Wow.
>> Yeah, already. I know. I
haven't even heard of the book.
>> That leads you to where to
get to your 100 books done.
If you just click it, it
will mark it as read.
>> Yes. There I already read it.
>> Then I'm going to predict
that that date is an issue.
>> Yeah. That date is also an issue.
>> Looking ahead.
>> Lots of problem is going on here.
>> Okay.
>> Yeah. So what's supposed to happen
is when I select 'I
finished this book',
this value should increment by one.
It's already saying I read one time,
which is ominous in and of itself.
>> Okay.
>> So if I say that I
finished this book,
it should jump from one to two,
but if I do it in this case,
it's jumped from one to four.
So either I subconsciously
read this book three more
times in the last three seconds,
or there's something going on
in Visual Studio and my code.
>> Then the date changes.
>> Yeah. All right.
So let's see if we can
fix that problem of
reading it three additional
times out of nowhere.
>> Okay.
>> So I'm going to
set a breakpoint at
the start of my index function here,
and that will hit when I
go back to my shelf page.
From there, I want to hone in on
that specific book which
was called Middlemarch.
I can't even remember the title
and I read it three times.
So from there, instead
of simply expanding until
I find what I want,
I can use the brand new
search tool available and
the Autos, Locals, and Watch windows
for our Visual Studio 2019.
>> Oh, yes.
>> So from here,
I'm going to do Middlemarch,
I think I can just say middle.
As you can see, I'm directly
taken to where I need to go.
>> That's so cool. Again,
that is new in 2019.
>> Yeah. It is brand new.
>> Now, I remember correctly
you wrote a blog post on that.
>> I did. I recently wrote
a blog post on that,
where you can go to
aka.mswatchwindowsearch,
and then check it out.
>> Cool.
>> For more detailed info.
So from there, I have that.
You'll also notice that
as I start typing,
it will automatically
start highlighting for me.
So in the case you don't want
to execute the full search,
you can just type away and
if it's visible on screen,
it will start highlighting
and you can find things
that way as well.
Especially, this is
really nice if you have
a bunch of items in
the Watch window at a time,
which can save you
the trouble of having it all.
>> Does that do both the
name and the value?
>> Yeah. So you can search for name,
value or type if you wanted to.
>> Okay.
>> So if you just wanted
to see all the types,
I can search a reading list and
as you can see I'll start going.
>> Okay. Cool.
>> All right. So from
there I have Middlemarch,
and I'm specifically interested
in a property that this book has
called timesRead and
this is the property
that's supposed to increment
every time I finish it.
So I'm going to go into timesRead,
and this time I get
a notification telling me
that it couldn't be found,
but luckily, it's giving
me the suggestion to
bump up my search depth
to a larger number.
So I'm going change the search
depth here to three,
so that I can search more thoroughly.
>> Does it default to two.
>> For me I set my default to two,
but normally when you first download
Visual Studio for the first time,
it's set to three.
>> Where do you change
that, is that an option?
>> Yes.
>> Or just remember
the last thing you set.
>> Yeah, it will remember.
>> Okay. Got it.
>> So if you set your search depth to
10 and then you exit out of
the session if it's reading one,
it will remember that you were at 10.
>> Okay.
>> Yeah. I'm going to
bump mine up to three,
and then I'm taken to
that particular property,
again saving some time of having
to remember where that property is.
Now, the case that I'm
trying to deal with is,
why is this timesRead property
changing without my knowledge?
Normally, this is when I might
have to play some trial and
error and try to narrow down
where it could possibly
be coming from,
but I ultimately don't know
where that location could be.
So I can use something
called a data breakpoint,
which has existed in C++ for awhile,
but is brand new to manage
code users in .NET Core 3.0 in 2019.
So this is a breakpoint
that will allow me to halt
my code when a specific
object's property changes,
even if it goes out of scope.
So I'm going to use that in
order to track down the problem.
So I can right-click on
that property and then select
"Break One Value Changes".
I know that the data
breakpoint has been
created because I have
the standard breakpoint icon there.
>> Nice.
>> Yeah. Of course I
can see it along with
the rest of the other
breakpoints that
I have in the breakpoints window.
Then if I scroll up a little bit
to the top of this item,
an object ID has been created,
and this is how Visual Studio
will be able to keep track
of that object if it ever goes out
of scope while my program is running.
So from there, I'm
going to hit "Continue"
and perform the same action again,
and hopefully I get
some quick fast useful information.
Yeah. So this time I
get an a notification
telling me that my data
breakpoint has been hit,
with an added bonus
of telling me what
the previous value of
that particular property was,
and now what the new
current value is.
It'll also redirect me to
the exact location where
that change came from.
So in this case, obviously it's
coming from the property setter,
which makes sense, but ideally,
I'd like to know what called it.
So I can go into the call stack
and then just double-click here,
and then I'll be taken to
where that setter was called.
In this case, it's happening in
my get shelved book function,
which I don't need because I already
set the timesRead property
to be committed elsewhere.
>> Yeah. So you retrieve the list.
So the fact that you got the book
off the shelf is being
equated to reading it.
>> Yeah. Apparently.
>> Yeah. Okay.
>> That's what I did in
high school from time to time
if I didn't like the book,
like time to go to spark notes,
but I'll buy the book anyway,
just so it looks legit.
>> So there's
another blog post that you
wrote on this as well,
Managed data breakpoints.
>> There is, yeah. Yeah.
Definitely go check
it out at
aka.msmanageddatabreakpoints.
>> Managed data breakpoint.
>> Yeah.
>> All right.
>> Kind of a mouthful but.
>> We'll have these
in the show notes.
>> Yeah. Looks all good.
>> All right. Cool.
>> Great. So now that
I found the issue,
I'm going to comment out this line.
>> That is really
helpful because you're
now being notified when it changed,
and then go finding out why,
and then you get to decide whether
that's valid or not. Very cool.
>> Absolutely. So it can be great
in several different scenarios.
>> That can save a ton of time.
>> Right. Yeah. You
don't want to play
trial and error all time nonstop.
So this is currently a
Dynacore 3.0 exclusive
feature at the moment though.
>> All right. Okay.
>> So yeah.
You're going to need to get
3.0 and play around with that
if you want to check these
out in a managed code land.
>> Is it scheduled to make it
into framework or is that TBD?
>> TBD.
>> Okay.
>> We've gotten a lot
of feedback about that,
so it has not been forgotten.
We are acknowledging that
and go in from there.
>> Okay.
>> Cool. So going back and
performing that same action.
In this case, I'm going to read
some other book I've never
heard of called Mrs Dalloway,
but this time correctly it
tells me I haven't read it yet.
>> Okay.
>> So that's a good sign.
If I say I finished
the book and go back to it,
it's increased from zero to one.
So yeah, those are
data breakpoints and searching.
So data breakpoints again are
extremely useful for many scenarios.
In that case, I just wanted to
hone in on a specific object.
So it's great for that, especially
in contrast to if
you were to just set
a breakpoint on that property setter
where multiple objects
could be accessing that,
and maybe you don't want that.
>> Yeah.
>> It's also good if you have
a global variable
that's being accessed
across multiple files and things and
you don't know where
it's being modified,
and you can use that for this.
>> Yeah.
>> Or maybe you just inherited one of
your teammate's pieces of code
and you're unfamiliar with it,
but there's something
going on in it that's
causing a property to change
without your knowledge.
So then you can use
a data breakpoint to hunt it
down instead of having to play,
"Well, maybe it's in this area.
I don't know what
this piece of code does."
>> Yeah.
>> Let's try it.
>> Cool.
>> This type of deal. All right.
So from there, there's one last bug
that I want to deal with.
It's not so much of a bug, so much as
an added addition on my part.
But the line right
below read one times,
it tells me when I last
completed the book,
but I have a tendency to
read multiple books at once,
and can finished several books
in one day as a result,
so I'd like to know also
the exact time that I
finished it as well.
>> Oh, okay.
>> So that's currently not there.
So I want to go into Visual Studio
and see where I can add that.
So I'm going to set a breakpoint
at this line here that
returns that related String
about when I finished the book,
and refresh the page.
Just looking at it at first glance,
there's a lot going on on this line,
I have a nested function call
happening within a parameter
of an outer function call,
and then there's a property value
being fed, it's a lot.
So I want to break down
this line of code and
see what pieces of the String
are coming from where,
just so I have a better
understanding of what's happening.
So the first thing
I want to look into
is the Person.ToString function.
But as it stands now,
if I were to try to use depth into
or step-over or any of those,
there's not really a way to get into
that nested function from there.
>> All right.
>> So I can use step into
specific in order to
choose which of these function calls
I want to go to first.
>> Is that new in 2019?
>> No. This has been around.
Yeah. This is an old one.
>> Yeah. So it's been
around for awhile.
So I can right-click this line,
and I can go to step into specific,
and I'll get a dropdown with all
the different places I can go to.
>> Yeah. We need to add
a feature to Visual Studio where
when you hover over something,
it will tell you when
it first appeared.
>> That would be amazing, if
there is an extension for that.
>> Yeah.
>> It's like, Visual
Studio history extension.
>> Exactly. Yeah. Just for fun.
>> Yeah. So you can pull
your hair out wonder,
''How did I not know
about that seriously?''
>> You can load it over your friends.
>> Oh, man. Yeah. So from there,
I can select person.ToString and
just as if I were to use
the regular step into,
it'll take me into that function.
Yes, so super great.
So this one is pretty
straightforward.
It's just returning the
value of the parameter
that I gave it in which case
it was just my name.
So I'm going to step through
it and then step out.
Then I'm back to this line again.
So from there, now I want to look
into the FinishedToString
method here.
So again, using Step Into Specific,
I'm going to select that one.
Here, I'll be taken to
the FinishedToString method.
I have even more stuff going on here.
I have some string
concatenation going on.
So first, I just like to see what
is the exact return value
with this method?
But normally, in order to do that
because it's not currently set to a
variable at first, I
would think, Oh, great.
Now, I got to stop
debugging and set it to
an arbitrary variable and then
look in the Watch window or something
what that variable could be.
But another way that you can look at
this return value without
having to stop debugging and
do all that is to step to
the end of that function.
You'll notice that in the Locals
as well as the Autos window,
there is a line that has
the return key Word on it,
and that will tell you exactly
what's being returned
by that function.
So that happens by default.
So you don't have to do any other
additional leg work in order to
see the results of something that's
not set to a particular variable.
Another way that you can do this
is also in the Watch window.
So I'm going to add dollar sign
and then ReturnValue,
and then I get that same result.
>> Okay, cool.
>> So the added bonus
about being able
to do that in
the Watch window is that,
I can also add
format specifiers to it,
which are things that allow me to
temporarily view the contents
of the Watch window
in a different light.
So if I wanted to remove the quotes
around the string for instance,
because they're
redundant at this point,
I can add a comma to the item
I have here and I'll get
this dropdown which is new to 2019,
with a list of different
format specifiers I can use.
So instead of having to
memorize the giant table
that you'd have to look up online,
it'll give me some options
right off the bat.
So I'm going to select nq,
which stands for
string with no quotes.
Hit "Enter" in that
will enable it to pass.
>> That's just in the Watch window,
you're not actually
touching the running code.
>> Correct.
>> Okay.
>> I'm not filling with
the code itself at all.
Yeah. So great.
From there, I now want to step
into yet another function,
I have this finished
book string here.
But again, I am
now under scope because I've
reached the end of the function,
so I need to get back to it.
I'm going to use that to
next statement again.
There's several ways you can
use that to next statement.
I can actually drag the execution
arrow up if I wanted to,
instead of holding down the control
key, like I did previously.
So from there once more,
we're going to use
Step Into Specific,
and I'm going to select
FinishedBookString.
Here, I'm being taken to
yet another function with
more string concatenation going on.
So let's say, I wanted to
break down this line of code.
So I can use ReturnValue again.
Again, I'm going to step to
the end of the function.
This time, I have
the final result here, of course.
But if I wanted to break
it down even further,
then I can do that as well
by adding ReturnValue,
I can do ReturnValue1.
Now, give me the result
of this.Title.
If I wanted to get this last
read date thing over here,
then I can also do ReturnValue3,
and that will give me
the value of these two.
>> It's interesting.
>> This also goes for
if you're looking
in the Locals and Autos windows,
it will surely do things like this.
>> So why do that rather than just
if hovered over this .Title,
it shows you that information.
All right. If you hovered
over ToShortDateString,
it shows you that.
>> Yep.
>> You can also add those
to the Watch window.
So when would you list
the value of being able
to specify ReturnValue1,
ReturnValue3?
>> It's just another variation to be
able to look at what's being
returned on top of that,
you're doing it in the Watch window.
You can mess around with
the format specifiers and stuff,
and just keep everything
grouped together.
I like to say organize though.
I'd prefer to just have
all the ReturnValue group together.
>> Okay.
>> So all right.
From there, I have found where I can
add my time-related scenario
because I have
this ToShortDateString function
here that I don't need
in order to show
the full time and the date.
>> Right.
>> From there, I'm going to
continue running my code.
>> That is known as
edit and continue.
>> That it's edit and continue that.
Yeah, that's a magic that
sometimes it works,
sometimes it doesn't.
>> Yeah.
>> This is a scenario where it
should work because if
I refresh the speed.
>> I remember when
that was introduced.
>> Okay.
>> That's amazing.
>> When was it introduced?
Because I think that was interesting.
>> But they told you
then I meet to date
and I had to admit it a while ago.
>> Yep. So we are making-
>> I'm old enough to
remember when that
was introduced the first time.
>> Awesome, yep.
So isn't empty tool when it works,
we are making improvements
on it as we speak however.
>> Cool.
>> So yeah. From there,
I just refreshed the page,
and as you can see,
I now have the time.
That was ReturnValue,
Step Into Specific,
Format Specifiers,
and then Set To Next Statement
made a reprise as well.
>> Cool. So now the app is perfect.
>> Yeah. Now it's absolutely
perfect. There is
nothing wrong with it.
I'm never going to have
any trouble with it ever again.
>> Cool. So over the course
of these two parts,
we've obviously seen some things
that we knew were in
there, learned a lot.
I saw a number of things I
didn't know were in there,
including some things that
have been in there for awhile.
So this has been
great. Thanks so much.
>> Awesome. Thanks for
having me yet again.
>> Hope you guys enjoyed that.
We will see you next time
on Visual Studio Toolbox.