Hello everybody and welcome to this video where I
want to go through some of my favorite things in
Visual Studio 2022. My name is Mads Kristensen and
I work on Visual Studio and I have for the past 12
years and I just want to share some of my favorite
things, because I think that there's something
here that you might not be aware of that will make
you more productive and more happy as a developer
I want to go through a bunch of new features
some updates some tweaks to existing features
that kind of just makes it all feel a lot
better to be a developer when we're using
Visual Studio. But before we dive in where I
want to begin is with the new kind of reality
in the way we work right. A lot of people have
gone back to the offices but a lot of people
have not and then there are people that are
sometimes in the office and sometimes at home
And when we have environments like this
we tend to move between different screen
resolutions and different monitor setups.
So, for instance even though when I'm at
home sometimes I take my laptop out of the
docking station here and I sit in the couch
and I do a little work from there. In that
situation, I just have a small little screen
but when I'm up at my desk like I am here
I have a one of these ultra-wide monitors,
so that's a completely different layout right
and when I go to the office I will I might
have multi-monitors and, so I want to make sure
that no matter where I am where I'm plugged in
what screen setup I've got Visual Studio is
always in an optimal condition to allow me
to do my best work and so let's take a look at
some of the cool things that we can do with that
So, here I have visual studio and you know and
I have my various different windows like the
Toolbox and I have the Solution Explorer out on
the right side here and this works well for this
particular monitor with this resolution that
I'm using right now when I'm sitting with my
laptop I want more of a kind of a minimal layout
like this so in this situation I have a small
screen so I don't want all these tool windows
to show up I need that extra space to code
and I actually also have a kind of a
separate thing is when I work on extensions
I like my layout to be a little bit different
so I write extensions for Visual Studio and
when I do that, I always want like the errorless
to be visible like you see here, and I show a third
tool window over here by the Solution Explorer
but that's only relevant for when I do that
if I work with websites I might have other
requirements different tool windows like the
Task Runner Explorer or other things that I
want to have shown that I otherwise don't
need and then when I'm at my ultra-wide
I really like to spread out horizontally over
that big area and so it will look something
like this now this doesn't look very good
on this monitor and this screen resolution
that I'm using right here but maybe you can get
the idea how I can like spread out horizontally
Let's go back here so let's say you have dual
monitors you could actually take the different
tool windows in Visual Studio and spread
out on these various different monitors
so I don't have that here for this
video so we'll have to pretend
So, let's open a window here. A
tool window - the Test Explorer
and let's imagine that I take this and I drag
that onto my secondary monitor okay and maybe
I'll make it full screen or make it really
big so I can easily see all my unit tests
All I have to do to save that windows layout
so I can easily come back and forth to it
is to go to window it's a save window layout and
then we give it a name let's call it "testing"
and that's it so now I saved this layout
if I go back up to window you can see that
I have all of my saved window layouts
right here and I can apply any of them
For instance, we can go to this one and
then back to the one we just created
"Testing". And I can do that with keyboard
shortcuts to make that very very easy and fast
So, this is super helpful I use this every day all
the time as I move between different development
scenarios but also different monitor setups so I
can't recommend this high enough go check that out
it was a feature we were introducing
in Visual Studio 2019 and we've been
improving it uh as time has gone by so
super life saver for this new world a new
situation with dual monitors and oh sorry
multi-monitors for different locations
All right, so here's another thing. I have my
code base here I got a bunch of files open
but I can't really see how many how many
files do I have open and it you know I don't
really know I can only see what whatever my screen
resolution allows me to see how wide the screen is
and that's why we always have had this
little thing up here you can click next to the
the tabs and if you click that, now notice how
you can see the list of open files
There are some that are grayed out and italics.
Those are the ones that are not visible right now
And then we have the ones that just look
kind of normal. Those are the ones you see
on the screen. And the one in bold
is the one that's currently active
So, that makes it really easy for me to get a
picture of what's open and where can I find things
But you know, sometimes I kind of just want to see
everything all the time all the open documents
So, if I go to the settings icon I can
now click "Show tabs in multiple rows"
and what's really nice here is that if you have
the screen real-estate - if you have the vertical
space, you can now stack all these tabs so you
can see everything that's open. Very very handy
But there are some monitors that are you know
have you know that are extra wide for instance
and in those it would be kind
of nice if we can take our
tabs and instead of having them on top then
move them to the side where we have more space
So again, go into the settings and
click on "Place tabs on the left"
So, it's really nice I can resize
this to whatever. I want to make it fit exactly
my monitor here right so what I'm doing here is
I'm getting that extra vertical space. I can now
see maybe a couple lines more of code in the
editor because I moved the tabs to the side
But let's see what else we can do here because I
have all these open documents and you can see by
default, it's actually kind of nice they are sorted
by the project they belong to, so my solution has
multiple projects and they're all listed under
each of those projects. That's very nice I don't
have to sort that or, sorry, group by project. I
don't have to do any grouping at all, but I really
like that so now it's just alphabetically sorted.
But I want it to be group by project like here
And if we
take it one step further here what if
we colorize these documents per project
So, now each tab has the same color if
it belongs to the same project and that
makes it even easier for me to kind of
at a glance see where these files belong
If we don't want it per project because
I already group my tabs for project here
Instead, we could do it by file extension so
that's also very handy, so I can see all my Razor
files, all my C# files, all my JavaScript
files. They all have a separate color so
it makes it easier for me to get that overview and
that might be exactly what you'd like to do here
And as a new thing we can also go in and
say, let's do it by regular expression and
let's configure the regular expressions. So, it's
a file here that opens up and I can start typing
I'm just going to copy that line up
from above and let's say we want to do
CSS and as soon as I save the file we can see
the CSS file has now got updated with a color
we have Razor I want to have something specific
here and we can even take it further we can say
you know everything that contains the
word um you know category let's say
so like something like this foreign so not all
everything that has the word or c-a-t-e-g will
be colorized so you can do that by folder
you can do that by file name and all these
things so you can really customize how you
colorize these tabs it's pretty phenomenal
And, of course, if you move uh back up and use
the tabs on the top they maintain their colors
so that's really really nice so let's go back
to per project I kind of like to do per project
when I have the tabs up top and that um because in
this case they're not grouped by a project and so
having them colorized by project is my preference
yours might be different but I really enjoy this
So, colors can be very very helpful to us when
it helps us kind of identify the different files
and so on but there's another thing where
I feel a color is a big deal and it has
to do with us sitting in Visual Studio using
visual studio for you know eight hours a day
10 hours a day sometimes five days a week
right. This is this is home away from home
and just like you do with your regular home you
want to have a certain furniture you put in your
house right you have uh what colors do you want
your walls and so on you want to make it yours you
want to make it feel like a place where you're
comfortable and visual studio is no different
so what's really cool now in in Visual Studio
2022 is that we have made it such that you can
take any visuals any Visual Studio Code, VS Code
color theme and convert that to a Visual Studio
color theme very easily and there's a bunch of
these available out on the extension Marketplace
and I want to just show you a few right here so go
to tools theme and you can choose from any of the
themes that you've got installed of course you
get some out of the box with Visual Studio you
can choose from and you can always go
and say click for get more themes and
that will get you to the Marketplace where
you can install all these different themes
and they're fantastic there's so many great
ones in here and they really help us if we
want a nice dark theme if we're sitting in a
dark room for instance and we can even have
Visual Studio changed the theme automatically
when Windows changes its theme there is this
thing here called use system setting and when we
do that if Windows is running in a dark theme at
night for instance after sunset Visual Studio
will automatically switch to the dark theme at
that point in time and back to the light theme at
Sunrise if that's your Windows settings right so
that's really really cool so a whole lot of colors
that makes our lives better in Visual Studio 2022
but let's change that back
to the blue theme for now
and I'm gonna change to a different
project here so here's a just a very simple
.NET console app and I want to show you some
cool things and improvements we've done to the
AI-based coding assistant in in Visual Studio
so I'm gonna type a new line here oh
and notice how Visual Studio automatically
will suggest that I put in a last name which is
exactly what I want in this case I want the last
name property to be inserted for me right here
I also want the full name so let's hit
enter again and this time it suggests age
which is could be could be the accurate one but
I want full name so I'm just going to pretend
it's not showing me anything and just start
typing public string full name and notice here
I can just hit tab and I get my full name and
it understands that full name is a product of
first name and last name this is really really
fantastic so the AI engine here in Visual Studio
understands the context I'm in it understands
that I'm right under the first name property
chances are that I might want another property is
relatively big and based on the name it also then
first name it then also suggests hey the last
name is usually what other people will add when
they you know as the next logical property but
what I was really impressed by was the full name
that it understands what a full name is right
it understands that when people have a first
name and a last name and they need a full name
this is what they want absolutely fantastic here
Let's scroll down and you can see here
I have a method here called remove data
and all it does it removes some data from
the list that I have defined above it
so what's missing here is a method for adding
data so again I'm going to hit enter and
Visual Studio already knows what I'm gonna do
here. I'm going to create an "AddData" method
so notice that based on the name remove data you
know it understands what remove means and add
and so it suggests that I created a method
called "Add" but what was crazy was that it
knew what that would do inside the method
right so it knew that it should not take
the list and remove something it should add to
that list so this is just absolutely fantastic
here I'm just coding by tapping enter and hit
hitting the tab key here it's absolutely great
and we can take it a step further so let's say
that I want to create a new method or I want
some code but I'm not entirely sure how I should
write it what I can do is that I can express it
in a code comment like this one so here I have
a comment it says take the two arguments and add
them together so the args refers to the args
that come into the to the main method up here
so I'm just writing here in plain English what it
is that I would like to have
happen and now I can hit enter
and Visual Studio will automatically
suggest what that code might look like
so it understands what I'm saying in English
in the code comment and can translate that
into something that is might be what I
want so this is absolutely fantastic so
this is the AI engine that is built upon a huge
data set and using machine learning it's able to
take the context that the AI engine is aware of
and pair that up with the big machine learning
model of what do people do in situations like
this that's basically what the machine learning
model knows and when we pair those up together
Visual Studio can do amazing things like this
so um a big step forward for the AI
engine here in Visual Studio 2022
now let's call our new method here the "AddData"
"AddData" and we're just going to give it
some string what are we going to call
it we're going to call it just one
here and I'm gonna just duplicate the
line Ctrl+D duplicates the line like this
and then we can I'm using an extension here called
Shifter that lets me change integers and other
things by keyboard shortcut here Ctrl+Alt+Up/Down
and so now I can fill my list here with data
now let's set a breakpoint and I'm going to
set a specific type of breakpoint this is a
new type of breakpoint temporary breakpoint so
what's really nice about a temporary breakpoint
is that it disappears as soon as the debugger
hits the breakpoint so let's run this console up
so here it runs and it comes down here and you
see the breakpoint is now gone right the break
point is gone because it was temporary it only
hits once so let's stop debugging here and um
let's scroll up so here on line 18 I'm making
a method call into a nougat package called
Newtonsoft JSON and I don't really know what's
going on inside the method called serialize object
I might be able to find the source code
somewhere on GitHub and then go figure it out
but it would be really nice if there's a way for
me to just go straight to the definition hit F12
and go to definition so let's try that and it
takes me straight to the source so this is not
um disassembly or anything like that this is the
actual source code using something called Source
Link all NuGet packages can opt in to Source Link
and that will allow Visual Studio to understand
how to get to the actual source code that made
up this particular version of this NuGet package
and even when you're inside these files you
can keep hitting F12 you know go definition
until we come down here and it's a serialized
object internal and this is a private string
so I'm F12 and I'm going to definition
through a file that made up the NuGet
packets that I'm working on and I can see
everything that's happening super helpful
all right I want to switch over to uh
different project and I'm going to open it
here it's the one I had opened just before
notice how how when I open it up here all the
files that were opened before are now open again
and in my Solution Explorer I can see
that all my folders and projects have
all been expanded to the same levels that
they were last time I used this project
and that's all good that means that I
can get right back into where I left off
but very often this is not what I want very often
I come in I open the project in the morning to
start working on something and I don't want sort
of yesterday's state to be expanded into Visual
Studio I want something clean I want something
fresh I want that fresh car smell in the morning
right I come in I just want none of this open
but I want to be able to open my app and work
with it so I'm going to show you a couple
of settings that are really really helpful
so if you go to Tools > Options and then go to
Projects and Solutions there are two check boxes
that are really good to uncheck here if you're
if you're someone like me that likes that fresh
car smell so "Reopen documents on solution
load" I'm going to uncheck that and "Restore
Solution Explorer project hierarchy state on
solution load" I'm going to uncheck that as well
so now let's go back to the previous
console lab here we can see that
the document was not open and the demo console
project over here is collapsed it's not expanded
so now let's open this project again that
we had before I'm going to switch again
and first of all I don't know if you notice this
but it's instant the loading of these projects
are now instant because no other files have to
be opened no state had to be read from disk and
hydrated into memory and applied on the UI thread
in Visual Studio to expand all the tree notes
in Solution Explorer none of that was necessary
when you open a file let's say you open a C# file
if it's the first time you open a C# file in
that instance of Visual Studio that you've got
open then it has to boot up all of Roslyn and
everything to get IntelliSense and colorization
and all of that working and that's called a
language service and a language service can
sometimes take a little while to load
now it's not necessarily a long time
but it's not instant like it is if we don't
need it and we do like I do here so this is
my default this is what I always do just a little
performance trick if you like the fresh car smell
come on all right I'm going to show you a
one of my favorite new features that we are
putting into Visual Studio this one started its
life as a an extension and it's now coming into
visual studio so let me let me demonstrate
that so let's say I want to add a file to
my project you know I can right click go down to
add and new item and that gives me this dialogue
but what if I go in to Tools > Options
here and click a preview feature flag here
and what I want to search for is here enable
quick add okay so now when I right click and
say add new item or kick Ctrl+Shift+A is the
same thing I get this little dialog up instead
so I can still click on this link that's shown
as well that says show all templates which gives
me that experience that I'm used to but I want to
get the simplified view we call it the quick add
dialog and so in here I can just
type a file name so a name .cs
and that's what it does it just gives
me the internal class and this actually
respects if I have how I how my namespace
rules are in my editor config or in my
settings and it will do the right thing
it uses the templates behind the scenes
but it's a little bit more clever than that so
control shift a again for add new item to bring
it back up let's type something a little bit
more interesting let's what if we create two
files what if I create a Client.cs and IClient.cs
now let's try that I just comma separated them
and I now have those two files but check this
out IClient is an interface whereas Client is a
class so the quick add method or dialog is able
to understand that I client that pattern naming
pattern should match an interface template and
then give me that so that's really really handy
but I can also click create folders so
I'm going to create a folder here called
"folder" and you can name it whatever you want
and just end it with a forward slash hit enter
and now you have an empty folder I could
also have gone in and said okay let's do
what if I do some sub directories here
and then end with a file - file.css
so I can create subfolders I can create
files in those folders again I can comma
separate these to create multiples really
really handy to have all this working
so this is in the preview behind a feature flag
so you saw how I went into Tools > Options under
Preview Features and enabled this feature so I
can't recommend this highly enough I love this
thing I use the extension and for years and
I'm very happy that this is now in the box
So ,now that we have a CSS file open
let's write some CSS. Let's do background
let's do blue and let's do set
index you know three four something
all right so I'm going to show you an extension
here called Shifter it allows me to flip between
values in the editor really really easily let
me demonstrate so I have a keyboard shortcut
here Ctrl+Alt and then either the Up Arrow
or Down Arrow and so if I'm on a number here
like the z-index and hit up Ctrl+Alt+Up it
increments the number like this if it was a
I say 0.08 here you see it will know to keep those
values depending on the decimals and all this sort
of stuff so really really handy if you just need
to like increment by one or something like that
but we can do more it doesn't have
to be just numbers it could also
be colors so here's the color blue so
if I do Ctrl+Alt+Up I get Royal Blue,
Dodger Blue you see here it gets lighter and
lighter the color gets lighter and lighter
and lighter and then it gets darker if I go down
Dark Blue and so on so forth so I can flip through
these very easily I can do the same if if we
have a let's see here let's grab a color here
with the color picker that color right there
so if I have a hex value like this I can do
the same and it understands what hex is and it
knows it's a color in this case and so it will
make the color darker or lighter as I either
go up or down with the keyboard shortcuts
so I'm just going to write some invalid
CSS here we can do other things like
switch between true and
false or you know yes and no
or on off and so on and so forth right so so every
time we can toggle between kind of known values
shifter comes in and makes that super
easy for us Ctrl+Alt+Up and down
so let me pin the upper window here let me build
our project now notice what's going on down here
in the output window I'm
getting a very nice colorized
output here because I'm using an
extension that colorizes everything
which is really nice something is green or gray
means like it's fine there's no no problem but
let's introduce a syntax error let's forget all
right let's delete this semicolon and run again
so now yeah we get an error in the error list
but we also see that our output is now red
because there was an error so it makes
the output window really really easy to
kind of just glance over or skim and
you can see if you have anything red
or anything orange if it's like a warning and
that's just really really helpful so there's
a bunch of these extensions out there that you
can use the one I use is called VSColorOutput,
VSColorOutput so go check that out
really really handy thing to have
and the last extension I want to show you
is compile again is one called
Solution Colors so you may have
the issue where you have multiple instances of
Visual Studio open and how can you tell them
apart they all look the same what if it's the same
repo you have open in both but different branches
now they look almost identical the solution
names are the same all the all the files in
Solution Explorer are the same how do you tell the
difference between open instances of Visual Studio
well what we can do with Solution Color
is that we can right click the solution
and set a color so I can give it any color I
want or I can enable auto mode so auto mode
basically takes the solution path and the branch
name and other things and makes like a unique
color that it will always map to that same color
so if if I now open another Visual Studio here
we can see here it will apply a color as the
solution is low to see this one turns blue
you can see the blue color up here and the other
one got the magenta color or pink right up there
now I can go in here and go to options
and make it a little bit more visible
I can go and say instead of just colorizing
up here the up there and it also puts a line
at the bottom of the screen you know maybe I
want a little bit extra maybe I want it on the
let's hear let's look at the borders instead
of just the bottom what if I wanted at the top
as well so I'm gonna go ahead and do that
and so now I have a thing here at the top
this is very very cool because
now I can very very easily see
that this is the you know I have a
magenta one I have a blue one and so on
and I can even tell by hovering down in the
taskbar those colors are also present here
under each of the thumbnails in the
Windows task bar
and if I don't like magenta I don't
have to have the even though we have
auto mode is on I can always say no
no I want you know give me a burgundy
and I can keep that color and all all other
solutions will still have the automatic one
except for the ones that I manually said hey no
no I want to specify the exact color for this
particular solution and of course I can also hit
the custom one and then select any color you know
RGB color that I can find here so or that that
exists rather so you can be really really specific
here and it stores it um in the .vs folder at the
solution root so it's not something you want to
check into source control you can but it's not by
default so this is just a personal setting to you
having you having put colors on yours does not
change the colors that your team members might
have chosen for theirs or if they don't want
any colors that doesn't make any difference
either because they're kind of
just local to you your machine
so this is called Solution Colors - Solution
Colors so throughout this whole demo you
probably didn't notice because there's no way
to tell that I've been working inside a VM
but not just any VM or virtual machine I've been
working inside a Dev Box a Microsoft Dev Box and
just you can tell there's really no way to tell
this is just Visual Studio running you can run
with any other app that I have installed that
I need to have installed to make my uh make me
able to work on the project I'm working on right
so it's it's just another VM but it's hosted in
the cloud and it's super powerful so if I go to
devbox.microsoft.com this is where I have access
to my Dev Boxes and this is where my it department
has given me the opportunity to create new
Dev Boxes that I can connect to so I have two here
I got Legacy and I got Podcast those are two and
they're pretty powerful uh eight core 32 gigs of
RAM and a terabyte of SSD very fast SSD drives
so depending on your workload you may want
to have a super-fast powerful machine or
if you wanna if you have a lighter
workload you can go sort of smaller
and it's very easy to create a new one so anyone
can just come in here say hey I want to start
on a new project I want a clean machine and you
just set it up very very easily from this website
so it's a very very cool technology it makes sure
that your Windows is always up to date and the
latest patches it's kind of a managed thing
your IT department can manage all these Dev
Boxes the way they can also manage your own you
know physical workstation or laptops um to always
keep them secure compliant up to date connect
them back to your network have all those things
um so that you won't even notice that you're on
a VM and the first time I tried this I was I I
will admit I was a little bit skeptical
but I signed in for the first time and
OneDrive started synchronizing my files so all of
a sudden I had all my files everything was there
all the images and all these different things
that I have on my Desktop and you know in the
My Documents and whatnot it was all there and the
image came pre-installed with Visual Studio and a
bunch of other tools that I needed so I could just
get to work immediately and it really didn't feel
like it was like a a VM that was hosted in the
cloud or anything like that it felt just like
another one of my machines and um I'm very excited
for this I have I have a specific specific use
case uh which is you know Visual Studio sometimes
can use a lot of uh resources when you compile
all the time and run debug and all that sort
of stuff it takes a lot of resources we want
it to take a lot of resources right we wanted to
compile as fast as possible we don't want to sit
and wait so we wanted to use be able to use all
the resources that we've got now the problem with
that is that it for me I have a laptop and it kind
of drains the battery so I can't use Visual Studio
on battery on my laptop for very long but with
Dev Box I can I can go all day long because I
don't do any of that heavy lifting locally on
my laptop it all takes place in the cloud with
much beefier hardware than what I've got in my
laptop so I get a much faster experience and I
get battery that lasts all day it's perfect so is
it public preview you can go ahead and try it out
um I encourage her to do that I think it would
be fantastic and um there's a whole admin story
for your it admin you may want to uh talk to
them about it as well because there's a whole
opportunity for them to make this secure and
compliant and all this sort of stuff making sure
that you don't spin anything up uh that they don't
think you should and um it's so it's a win-win
it's a win for the developer and it's a win for it
you really get that flexibility that productivity
that and get all the hardware you need when you
need it so um go check out Dev Box - Microsoft
Dev Box and that was it for this uh
brief video of me going through some
of my favorite features in Visual Studio 2022
new features are added all the time so make
sure you go check it out uh install the latest
version and try it out for yourself thank you
Wednesday, February 4, 2026
Cool features in Visual Studio 2022
Death to SQL Server! Long live SQL Server! How containerized SQL Server makes development easier
alright hey everybody we are lives thank
you so much for sticking around we just
had minor technical difficulties which
is the theme of the day with Skype so Oh
Mike and you seem you are you there i
yes I'm here your video looks frozen but
that's ok you look like you're mad the
way I'm so mad so what are you speaking
to us today about Mike so today we're
gonna talk about using sequel in
containers to do some development work
and just some random tasks that you have
to do without having to install it on
your development machine awesome let's
get started okay go ensure you screen
whenever you're ready oh well see it's
not showing you should be showing oh ok
well switch over there we'll do that
hopefully so there it is I see it now
there it is I've got as much hair as the
dotnet bot perfect but my beards not
nearly as pretty as Mark Miller's
without amazing or what that is so good
at that
yes yes so so yeah we're gonna talk
about some fun stuff or some what I
think it's fun my threshold for fun is
pretty low
I'm Michael jolly and I'm happy to talk
about using containerized sequel server
as part of our development lifecycle so
one of the greatest things about doing
this is this is all our twitch family I
see so many twitch friends and chat it's
just this is fam right this is family
time so let's talk about it let me tell
you a little bit about my background
I've been a software developer and
architect for a nearly 20 years
primarily focused on mobile and web I'm
live coding on Twitch three days a week
as part of the live coders team with
c-sharp fritz Jeff Ritz and I'm an
office hero i ambassador I love talking
about security so feel free to hit me up
on that because you know that's fun
stuff and when I'm not running code I'm
probably spending time with my fan
like playing music or trying to exit
them it's a losing battle so one of the
best parts of my job is to find new
technologies and tools and processes
that help people in their developer
experience and I'm excited to share one
of those with you today I've been using
it for write four or five months and it
is legit it is too legit in fact to quit
yes said that so docker we don't need no
stinking Dockers well what is docker
let's just go really quick high-level
overview you will not know all the
intricacies of docker after this but
what is it the easiest and some would
say too simplistic way to describe
docker is to compare them to virtual
machines they are not virtual machines
but both provides similar resource
isolation and allocation benefits but
they're fundamentally different because
at score doc VM that virtualize is
hardware whereas containers virtualized
the OS and really that's kind of a
heavy-handed way to describe it
containers reply be better described as
a system service they're isolated and
don't really know about anything you
don't specifically tell them about for
instance they don't need to know about
networking they don't need to know about
peripherals is that a word well it is
now and so on you know it doesn't have
to know anything about that it's just a
service that's running if you need it to
have network access you tell it about
network access if it needs to know file
access you tell it about file access
well another another reason we want to
use docker is because man the containers
the images are so much smaller compared
to like a VM image or just even a whole
install of sequel server the images can
be in the tens to hundreds of megabytes
versus gigs of just the install for
sequel right nobody but sequel in a
container what are the benefits to
putting it in a container why would I
want to do that well
I'll tell you why I'm glad you asked
first is the reduced footprint on your
local machine so if you've ever
installed sequel you know that it's a
big install and then I've got to deal
with updates periodically and I don't
want to I don't want to I don't want to
fight that battle right I mean I only
need sequel server when I'm developing
or maybe having to do some kind of data
manipulation for a client something like
that
you know I don't I don't necessarily
need all that stuff all the time
second one of the benefits is we get
cross-platform support so all of our
friends on Linux and our friends on Macs
who are developing can all kind of share
in the joy that is developing against
sequel without having to you know
install that there right and the third
one is one less although massive attack
vector on our machine if you've ever
installed sequel server and watched your
era logs you know firsthand that sequel
server is one of the most attacked
pieces of software in the world it's
insane and I don't want to be exposed to
that I don't want to think about that
right so by running sequel server in a
container you get all the benefits of a
full install while being able to throw
it away when you're done working with no
impact to your local development machine
that's right
hashtag not on my machine so let's let's
well before we get it to the demos I do
want to say you probably shouldn't be
running sequel server in a container in
a production environment while only a
Sith deals in absolutes I will say it
would be a very unique use case that you
would need to run sequel in a container
in a production environment but we can
use it for day-to-day tasks and to
improve our development workflow so
let's see it in action
are you ready first I'm just gonna show
you some some code we're gonna run in
the terminal spinning it up in a
container basically we're gonna run a
command we have to have docker installed
right that makes sense and we're going
to run that command up there that's kind
of in the teal
and basically to break down what each of
those points are you're setting two
environment variables one is the SI
accounts password shoutout dotnet comp
we're also gonna accept a EULA you just
got to do it name is optional but
recommended because it names that
container that's running and in
otherwise you're gonna have to reference
that container by like the ID which is
god-awful
don't do it you'll love me if you if
you'll you'll love me the minute you do
it and remember a Mike said don't do
that and then finally the dash D we're
telling we're telling docker what image
we want to use to build that container
so in this case we're using MMS sequel
server 2017 and it's actually running in
Linux so that's pretty cool wait let's
do that
matter of fact let's go back and let me
escape out of that and why don't we do
some magic in PowerShell so let me go
what we're gonna run that command trust
me we're gonna run it it's gonna be so
cool okay so there's that command I'm
just copying and pasting it in hit
go-go-gadget run and there it is
so it gives me this gala T and
that's that image you never want to see
that string so with that running we
should see some dr. containers running
so if I well I mean not use my aliases
let me the long form it here
there's our docker container look at it
it's beautiful look at that sucker
running for 18 seconds named sequel oh
one well so let's go through a use case
right so I can tell you we have a client
who oftentimes sends us a backup of
their one of their production databases
and says hey we've made some changes we
want you to refresh the sequel database
that you have and you're developing
against to have our newest stuff so what
it'll do it what will we keep their
database in Azure so they send us a
backup well normally you can just import
a backup file to Azure but you can't
have custom security logins with that
and wouldn't you know what this client
has
custom security logins because you know
customers gun a customer so let's go
into that directory I've got a folder
here and I've actually got a backup
right and I'm going to let's say we've
got that container out there let's just
do this let's talk about maybe can we do
it so we've got our container running
that's what we that we we we executed
this to do it now let's talk about
copying files in and out so basically
this customer sent me a backup file and
I need to get that security login out so
I can upload it to asher so we're gonna
run that command there with docker copy
and we're going to copy in the first
parameter is the source file the second
parameter is the destination file and if
you're going to use that you're gonna
use a container as one of the source or
the destination you need to prefix it
like container name or ID colon the path
so sequel one is the name of that
container I spun up so let's run that
same command and I'm going to in this
sources data folder I'm gonna copy in
that backup client gonna client dot back
and I'll come over here to my command
line copy up that to debt container and
it just comes up now one of the cool
things I did in this when we executed
the command to started up I exposed the
port that's up here port 14 33 I told it
hey in that container you have 14 30 14
33 map that to my local hosts my host
machines 14 33 so I can come into sequel
and connect to that sequel server using
the password look in here there's no
databases we just spun it up right
there's no databases here but I can come
in and say hey restore a database
because I copied that back into the
container
I can now magically select it there and
that bet you'll notice the path VAR r ms
sequel data that it no windows path you
know okay well thank you open it up
let's say now i know they've got yep
Shawn Hasselhoff I knew they had a
custom login in there so I'm just gonna
remove him I don't need it I'm just want
to get this okay Sonia I need to do a
backup backup yeah yeah default stuff
yeah just do it make it so number one
okay disconnect from that so now in that
container
I've got a copy of a backup file in
there that has that security login or
moved so I'm just going to let me see
let me copy that command in it's
basically the same copy command but the
parameters are back are swapped so I'm
gonna copy from the container out to my
local machine and here I've got a backup
and matter of fact if I go ahead and
delete that to show that it did it guys
you know don't want to be cheating here
there you go there's that backup from
the container that doesn't have that
security login so now I can go in there
and have fun with it so it's cool stuff
you can map drives matter of fact we can
um let's see let me come in to the
slides again let's slide on up in here
yeah yeah yeah that's a little late port
forwarding and volume mapping so we just
showed you port forwarding because we
added that p14 33 33 and that's mapping
it from the host to the inside we can
also map a volume it mop basically
mapping a drive right so in this case I
would be saying 'die sources data which
is a directory on my machine map that in
too far up in a cichlid data that'll be
a great way to persist that data because
once the containers are gone let me get
rid of that thing sequel 1d sequel one
goodbye to you so now we don't have any
containers and I'm gonna run the same
command again to create a container but
this time I'm gonna tell it hey map that
D sources data which is the folder we're
in over here to that directory inside
the container which is where Microsoft
sequel server stores its data in this
container so just hit that it's going to
execute there I got a container you
should be run
now and then look over here in this
folder all of a sudden my master
database starts showing up my model my
temp TB all those files start showing up
so now I can log back into that again
like a boss I can come in here and
create a new database yo
this is cool hit OK and I've got the
database in SSMS just like normal but
I've also got the MDF and everything
over here so now when I disconnect from
that you just get out of it I'm gonna
come over here and say you know stop
that container a matter-of-fact heck I
hate it so bad just delete that
container it's no longer on my machine I
don't have sequel installed on my
machine now but because I mapped that
drive I've still got the database and
the data that can use other places
that's the best table name ever and yeah
I mean all up in your chat reading
your messages yeah so so that's pretty
cool so we can do everyday tasks like
that but let's take it a step further
are you ready ladies and gentlemen are
you ready let's go into visual studio
because you know developer Gunn develop
so in here I've got a very simple app it
is so simple in fact that it will amaze
you all I've got is a couple classes you
know client class what's you're gonna do
it's got an A and create we're gonna use
some entity framework core right because
that's how that's how we play here and
then I've got some things you know
normally my connection streams gonna be
some environment variables super-secret
connection string but if I'm in debug
I'm gonna tell it hey the server is
called sequel demo the database is
called oMG data and there's my username
password now of course that's just in
debug right so there's just some stuff
we're gonna we have a method to seed the
data if we need it we got our model this
is all just EF core stuff we're not
gonna get into that but trust me it's
amazing and then we have one database
migration that basically builds out the
database with the clients and the and
the address table and then I've got this
like
web app does dotnet core MVC or asp net
core MVC app and all it's doing is
spinning up and in that home controller
I get that context from that thing
pull in the clients and return it to the
index view and the index view just
basically does a TR builds a table with
the ID and the name now my C data method
is running every time in my startup I've
got it telling it hey oh and she context
migrate that data police so that we have
it so then when I run it nothing's gonna
happen it's gonna bomb because it's
gonna say that database doesn't exist
except I have a docker file here because
of course I'm gonna eventually deployed
this asp net core app in a docker
container so I've got a docker composed
and that docker compose I say spin up
that doc sequel docker web app and call
it sequel docker web you know and then
it depends on this sequel demo service
which is basically the sequel 2017 we're
gonna call it sequel demo and because
it's in that docker container it's gonna
put those on the same network just
amongst themselves I've exposed the port
here so that I can access it with SMS if
I wanted to and then I've also mapped
that drive so that we can see the data
later on so that container was gone so I
can delete those files and I'm gonna
debug this web app and if all of the
demo gods have been sufficient
sufficiently appeased today we should
see a browser open up and magically
it'll be just the default asp net web
site except it should list one client so
let's see database method basically
seeds one client in one address and
right now it's starting up it's
compiling it all it's gonna spin up an
asp net core container and it's gonna
spin up a sequel server and there it is
look at that I've got one record with
just the ID that's a grid that the
customers name and when I get done I can
close this thing down
and stop debugging get out of it all I
can go delete containers now look at
that it created my oMG data database so
I've still got that that I can play with
if I need to I can access it I can spin
up that container and connect to it
through SMS if I wanted to
matter of fact heck let's do it why not
do it live let that thing start back up
we'll connect to that sucker like a boss
let's see we want to connect we're going
to wait for it to finish loading okay I
got my web app up so proof in the
pudding the web app is running so the
sequel server should be running ah OMG
data OMG data there's my clients my
addresses it's got the migration history
because you know that's how we roll with
EF core and that awesome I've got my
data there I can sample it an SS man so
if I'm debugging I think there's
something wrong with the data I can
still play with it and then I can close
it down so this is like legit just a
data base for me and my development
environment and when I'm done with it I
can say get out of here sequel and
you're not on my machine because I named
it I can just say doctor why don't you
remove sequel demo and sequel docker dot
wept because I'm done oh I had to stop
them d CX sequel demo I apologize for
the d CX that's an alias which you can
get from the dev toolbox
PowerShell extension it's pretty cool
and it also works better if you type the
names right justice you know little
helper there for you if he's typed the
name of the container right it always
removes it better so now I'm done with
Visual Studio I'm done developing but
because I mapped that drive I've still
got my data there if I want to use it or
if I didn't map it it could just go away
too which is wonderful
it makes everybody happy if you're not
happy with that well I don't know what
to tell you call Mark Miller because
that presentation was amazing
so with that thanks everybody for
listening to me talk about this it's
it's always fun to hang out with all of
you my friends on Twitch and the
interwebs this is the Michael John
that's right Bobby Johnson you can find
my slides the the code that I use some
additional links to help you start doing
this at that bitly link there well you
can find me on twitter at michael jolly
I know it sounds weird but you can also
find me on the web at Michael jolly calm
I know it's hard to remember and then of
course I'm streaming three days a week
on Twitch I'd love to see you there and
hanging out with you and and that's it
yeah anybody got some questions yes cuz
I've got answers we've got some I can't
hear me okay
I can't hear sweet so there we go
so yeah we have some questions that
people been posting people mostly having
issues with oh there you go perfect
thank you for turning the camera on and
off that was perfect
that's how we do it in developer land
that's right and off so with regards to
a hey EF and whatever else but the one
that's here that I think it's gonna
drive some good conversation is molten
MC backers asking why wouldn't you use
docker and sequel server in a production
environment why is that an issue because
okay so so si think of docker as like a
a service right a system service that's
running if you have like a little
process web app something very specific
like that perfect for that scenario you
wouldn't want to try you know thinking
about like micro services really right
but you wouldn't go put s ap in a
container it's just too much I mean
you're gonna you're gonna you're gonna
shoot yourself to be honest you're
you're not gonna last a year you're
gonna drive yourself crazy
same way with sequel server it's a
little too big and then you get into
issues of scaling that right for
instance like I showed you how to mount
a drive to like the host machine for the
data store that data persists well that
will be the only way to do it because
the containers transient it goes away
and comes back and come goes away
comes back well if you don't mount that
to a drive the data is gonna go away
with the container that is bad news if
you're running in production but if you
did mount it and you tried to scale that
sequel instance you're gonna have issues
because you can't mount all those
containers pointing to that same data
file and and live if things are gonna go
squirrely real quick when all those
containers are trying to access the same
MDF yep but it's perfect in these little
small scenarios where you have just some
tasks to run where I don't have to deal
with like the full big install I don't
have to deal with managing updates and
all that kind of stuff and firewall
settings to make sure I'm not being
attacked matter of fact if you don't
forward the ports to your host machine
like I showed you
there's no exposure at all I was totally
available in that little docker Network
it's really cool perfect yeah I was just
I was looking at the chat here and
Moulton backers it's like good cool good
to know thank you for answering my
question but that was really great good
good you everybody don't you
everybody loved the presentation you did
an awesome job I knew you I knew you
would but it's on our tech check a
couple days ago so thank you again
Michael for taking the time to chat with
us and share your knowledge and your
passion absolutely your humor with us
what were you funny now I'm kidding okay
so we are gonna for everybody watching
the stream we're gonna get Michael off
the the Skype here and get Swee key who
is our next presenter we're gonna talk
about mixed reality and xamarin know
this so we are gonna be doing that here
so we're going straight into the slate
and going mute for a little bit we'll
talk to you guys in a little bit our use
Debugging Managed Async Code in Visual Studio 2019
hi everybody my name is Leslie
Richardson I'm a program manager on the
visual studio debugging team and in this
video we're gonna talk about debugging
asynchronous manage code in Visual
Studio so async code can be really great
it can ultimately improve your programs
throughput and having keywords and
c-sharp like async and weight can help
make writing that code much easier but
it can also add an extra layer of
complexity that can make debugging it
much harder and on top of that Visual
Studio likes to hide a lot of
information that could help you debug
your async related issues by default but
on the bright side it also provides
several tools that can help make your
debugging experience with asynchronous
programs much easier so let's check
those out all right so I am using the
latest version of Visual Studio 2019 and
I've got a sample dotnet core console
application that consists of several
threads and tasks which we're going to
use in order to showcase the
asynchronous debugging tools now if you
want to follow along using this code or
you just want to use it in order to play
around with the tools that I'm about to
talk about a little further you are more
than welcome to do so
I have posted the link to this code in
the description below it's actually from
an older walkthrough that's available in
the Visual Studio documentation that
talks all about the different
multi-threaded and async tools that you
can be using while debugging so when
you're debugging tasks for the first
time or async code for the first time
one of your thought one of your first
thoughts might be how do you even view
all of your tasks or where can you view
them all at the same time because
ultimately unlike synchronous code your
codes execution may not be happening
linearly which can make trying to debug
it a little bit harder so one of one
option that you have is the tasks window
and the tasks window will give you a
tabular view of all of your tasks their
current locations and their status is a
break time so you can access this window
either by going to debug and windows and
then tasks if you're a keyboard shortcut
kind of person you can also use ctrl +
Shift + D comma K it's kind of a
mouthful but there it is
and you can also search for it using the
global search tool of course alright so
as mentioned this is a tabular
representation of all of your tasks you
can see their IDs you can see whether
your tasks are active blocked or waiting
you can also see what their current
location is as well as which thread they
are assigned to if you have a
multi-threaded application as well so
for example I can use this table to see
that task 3 is currently blocked and I
can hover over blocked let's see here we
go I can hover over block to see that
task 3 is currently waiting on task 4
which is owned by thread 15 3 2 0 and if
I look at that one I can see that it's
blocked and I can double click this
because it's currently holding onto a
lock that this thread is trying to
access so this can be really helpful if
you just want to quickly navigate
through all of your tasks at a given
point in time in your code in order to
better understand what's going on so if
you're like me and you prefer a more
graphical representation of how your
code is executing another alternative
that you can use to the task window is
something called the parallel stacks
window which I will open up by using
global search all right and let's expand
this window out so this one is pretty
cool because it provides you a graphical
representation of the status of all your
tasks and task related call stack info
so each block here actually represents a
portion of the call stack that shared
across one or more tasks and that's
defined by the async logical stack title
up here so for example when I first
started running this code all four tasks
in this program started in method a in
this block down here and then they all
ran through method B followed by C so
from there each task branched out to a
different method location as represented
by the separate async logical stacks
that branch from this original
here such as task 1 which went from C to
e task 2 which went from C to H and
tasks 3 and 4 which go from C to K and C
to J respectively so we've actually made
a lot of recent updates to the task view
in the parallel stacks window since 16.4
so let's skip ahead to another break
point to show some of that off more
right so same view different information
this time round but this time you'll
notice that not only can you view tasks
that are currently active but you can
also see tasks that are just scheduled
and haven't started running yet so
that's a new addition that we've made to
this window because in the past you
could only view active tasks also if you
want to see the call stack of a
particular task in its usual format via
the call stack window then you can now
double-click on any frame in the
parallel stacks window and it will show
you that tasks corresponding call stack
so if I wanted to see what task 1 is up
to over in this block here double click
S dot M and as you can see I can get the
standard tabular representation of the
call stack for that given task so if
you've debugged multi-threaded
applications before you may already be
familiar with the threads view of the
parallel stacks window which you can
switch over to via this drop-down here
and this gives you a very similar view
to the task view except this is all
thread related the cool thing about both
the threads view and the task view is
that you can use the two of them
together if you wanted to so for
instance you might have noticed this
waiting on a sink operation prompt that
shows up in a couple of these thread
blocks so if you wanted to know what
async operation is currently being
waited on you can either double click
this or select one of the frames within
the block right-click it and select go
to task and you'll be taken to the frame
in the task view where that weight is
occurring from so that's extremely
useful and of course you can do the
opposite so if you wanted to see what
thread task 5 is currently running on
I can right-click a frame and then
select go to thread and get the opposite
result so that was the parallel stacks
window and the tests window both are
extremely useful tools I actually like
to use them at the same time personally
sometimes I feel like having a tabular
view other times I feel like having a
more visual representation but either
way they're both great for better
understanding how your code is executing
asynchronously so from there let's talk
about another hot point of tension when
it comes to debugging asynchronous tools
and that's exceptions exceptions can be
a real pain in the butt sometimes when
it comes to asynchronous code especially
because Visual Studio likes to hide away
some of that info that you that would
really help you to bug those issues
properly so let's pivot over to another
application that I have in order to
examine how we can solve that problem
all right so with a little editing magic
I have now moved over to a different
simpler async program this one is taking
a method called a which just calls B
which calls C so all these are chained
together and ultimately I'm gonna get a
no reference error exception at this
line here because I'm setting a string
equal to null and then trying to set
that string to lowercase letters so I'm
going to run this program and as
expected I get the exception helper
telling me the no reference has occurred
only its redirected me to this line
where we're calling the a method that's
not the most useful thing to have
ideally I would like to get or I would
ideally like to find out the source of
where that exception was thrown from not
where the error altom utley becomes
unhandled so an additional feature that
we added in post 16.5 is this call stack
information that is new to this
exception helper so anytime there is an
exception that is getting read thrown
somewhere such as in this case Visual
Studio will actually provide the call
stack from where that exception was
originally thrown from so this is really
great and I can also just click the link
here and it will redirect me to that
exact line where this error was first
thrown of course it also tells me what
method it was coming from like a
traditional call stack would but if you
don't want to have to sift through all
your methods in order to find that
location then you can use a link so
having read thrown exceptions is very
useful for any kind of inner exception
that you may have but they're especially
helpful when dealing with asynchronous
exceptions which are typically caught
and then read thrown by framework code
so of course once you navigate to the
source of where the exception is thrown
from you can always set a breakpoint for
next time and then try to debug the
issue from there and inspect anything
that you need to inspect of course the
downside to simply using really thrown
exceptions is that you don't get to use
any watch window tools which would allow
you to view all the variables
functions and all their values that
occurred at that given point where the
exception was first thrown from so as an
alternative in order to help you out
with that element of debugging your
exception we can navigate over to the
Diagnostics tools window which is that
tool I find myself closing from time to
time but don't sleep on it because
there's a lot of nifty things that you
can check out such as this events tab
here which as you can see has documented
every time an exception has occurred and
at what point in time that had happened
at so specifically I want to look at
this exception notification here that
has a little camera icon on it and that
is a sign that a snapshot of this state
of this application state is available
so what that means is when this no
reference exception was originally
thrown Visual Studio actually took a
snapshot or saved the state of my
application at that given point in time
and what I can do now is double click
and it will take me back to that exact
moment in time where this exception was
first thrown so as you can see I get a
notification telling me that I'm now in
historical debugging mode so I'm in the
past very mysterious
from here I can look at the autos window
locals watch as if I were debugging
regularly in the president I can also
check the call stack which can be very
helpful and this is giving me the call
stack of that given point in time where
that exception was first thrown so
there's a lot of really cool debugging
tools that I can still use even though I
am currently looking in the past so in
order to use snapshots you may need to
enable them if they're not turned on
already and at the moment this is
currently a tool that's only available
for Visual Studio Enterprise so if
you're an enterprise user definitely
take advantage of it so to do that we
can go to open and tell a trace settings
and intellitrace is a larger feature
that we have in Diagnostics land that
includes snapshots so make sure
intellitrace is enabled and then select
and tell Ettore snapshots and where to
get the snapshot part
and select okay and you should be good
to go so in summary there's a lot of
really nice to bugging tools that can
help you diagnose your asynchronous
issues a lot smoother we talked about
the parallel stacks tool which provides
a visual representation of what all of
your tasks are doing what their current
statuses are at a given point in time we
also talked about the task window which
provides a tabular representation of
that same information we discussed
wreath rone exceptions which will allow
you to see the original location of
where an exception was thrown from and
we also discussed snapshots which will
allow you to diagnose your asynchronous
exceptions at the exact point in time
where it was originally thrown and that
concludes this video thank you so much
for watching hopefully you learned
something new about how to better
improve your asynchronous debugging
experience and as always if you have any
thoughts comments or suggestions on how
we can improve any of those asynchronous
tools or just anything in the debugging
space don't forget to reach out on the
dev community and with that happy coding
