►
From YouTube: .NET Design Review: Nullability Custom Attributes
Description
We'll take a look at applications of new custom attributes to help the nullability analysis.
A
A
A
A
Similarly,
you
can
say
this
is
attributed
to
take
know,
but
we
don't
allow
null
and
that's
the
disallowed
null
attribute
and
then
the
same
kind
of
corollaries
exists
for
the
out
direction,
so
you
can
say,
even
though
something
is
that
is
attributed
such
that
it
doesn't
look
like
or
it
may
not.
I
may
not
return
null.
It
actually
can
that's
the
maybe
null
and
then
there's
even
though
it's
something
attributed
to
say
that
it
could
be
null.
A
A
A
Well,
you
could
basically
say,
and
a
parameter
may
be
no
when
referring
to
the
return
return
position,
so
you
can
say
like
upon
the
completion
of
this
method.
This
parameter
may
may
be
known.
That
applies
both
to
refs.
It
also
can
apply
to
an
input
position,
so
you
can
say
like,
for
example,
string
is
null
or
empty,
we'll
have
a
what
is?
It
may
be?
No,
when
true
on
the
string
parameter,
because
if
is
null
or
empty
returns
returns
true,
then,
obviously
the
input
parameter.
A
Could
have
been
known
and
then
there's
also
a
not
null
when
and
so
on.
Then
there
are
also
attributes
that
are
around
control
flow.
There's.
It
does
not
return,
which
is
only
about
null
ability.
It's
not
about
general
control
flow,
just
in
knowable
flow
and
also
it
does
not
return.
When
for
a
boolean
parameter,
we
applied
that
to
debug
assert,
for
example,
so
debug
assert
has.
A
C
D
C
A
A
C
A
Prop
the
problem,
is
you
want
the
calls,
after
resize
to
not
have
to
bang
on
the
access
to
the
array?
So
you
know
if
let's
say
you
have
you've
initialized
a
tee,
open,
brace,
open
bracket,
close
bracket
question
mark
array
equals
no,
and
then
you
call
resize
ref
array.
You
don't
want
to
have
to
then
use
an
exclamation
point
to
access
array
after
this
call,
if.
F
E
C
E
B
A
A
A
D
C
B
A
B
B
A
C
A
So
these
are
interesting.
The
the
common,
the
most
common
use
of
the
win.
These
win
attributes
is
on
try
methods
where
you
have
an
out-
and
we
say
it's
you
know
not
know
when
true
or
maybe
know
and
false
and
in
general
the
rule
is
or
the
guideline
is,
if
it's
a
non-generic
you're,
typically
gonna,
see
and
not
know
when
true
and
if
it's
a
generic
you're,
typically
gonna,
see
them,
maybe
Nolan
false.
A
Wait
wait
because
if
it's
a
non-generic,
then
we
explicitly
specify
it.
We
know
that
that
we
know
the
null
ability
of
the
type
that
we're
specifying,
and
so
we
can
be
strong
about
it.
We
can
say
we
know
that
this
will
not
be
know
when
it's
true.
If
it's
a
generic
like
let's
say
it's
a
dictionary
of
T
key
T
value
need
to
try
get
value,
it's
possible
that
you've
constructed
T
value
as
a
string
question
mark
and
then
even
if
try
get
value
returns.
True,
it
may
still
be
known.
A
So
with
most
generics
in
most
cases,
we
have
no
choice
but
to
be
strong
in
one
direction,
but
not
in
the
other,
and
then,
if
you've
actually
constructed
T
value
to
be
non
knowable.
Well,
then
your
T
is
non
nullable,
and
so
the
normal
compiler
rules
rules
apply
and
so
you're
still
gonna
kind
of
get
the
best
of
both
worlds.
So.
A
C
F
So,
for
example,
let's
say
you
do
try
create
and
you
put
it
in
an
F
and
then
you
reference
that
variable
that
you
try
to
create
it
inside
that
block
of
the.
If
you
hover
over
it
and
you'll,
see
the
type
and
you'll
say
not
know
at
this
location,
and
then
you
go
to
the
else
and
you
use
it.
It'll
say
not
with
this
location:
big
good
text,
yeah.
A
A
E
C
D
A
C
F
C
E
H
E
H
A
Yeah
I
think
we
just
need
to
remove
the
attribute,
I
think
I
or
whoever
did.
This
was
probably
thinking
that
you
know
it
can
return
null,
but
the
inputs
shouldn't
be
no,
but
it's
only
that
the
input
shouldn't
be
null
for
certain
T
values
and
therefore
you
don't
have
a
way
of
saying
that,
and
so
we
should
remove
it.
Just
so
I
know.
F
A
E
I
think
it
already,
there
should
never
be
knowable.
What
dictionary
allows
an
open,
I,
don't
know,
but
MSDN
doc
says
it's
totally
like
there's
there's
an
actual
sentence.
It's
an
interface,
so
anything
is
legal.
We're
documenting
here
our
belief
that
you
should
SML
key
because
most
of
our
dictionary.
C
E
E
A
C
E
G
I
A
A
F
Seems
like
you,
you
probably
got
in
an
elevator
when
you
didn't
intend
one,
maybe
or
maybe
I'm
reading,
sometimes
some
type
of
input
from
a
user
and
I'm
looking
to
see
whether
or
not
sure
but
then
say
argue
with
the
plans.
Right
I
mean
that's
right,
I
mean.
Certainly
today.
If
you
search
it,
if
you
search
a
collection
of
string
or
now
it
won't
throw
I.
E
E
A
B
C
H
C
A
D
A
Where,
for
whatever,
for
whatever
reason
from
in
the
design
of
the
thing,
we
basically
just
said,
you
know,
no
one
ever
pays
attention
to
this
thing
being
null
and
therefore,
if
you
pass
null
it's
gonna
blow
up
and
that's
like
to
get
hashcode
case
most
of
our
implementations.
If
you
pass
knowable
just
know
rough.
F
C
F
C
A
C
B
A
If
it's
I
believe
and
Fred
can
correct
me
if
I'm
wrong
I
believe
if
you
implement
it
with
a
non-generic
like,
if
you
implement
a
tie,
equality,
compare
of
string,
I
believe
for
something
like
equals,
you
wouldn't
have
to
or
I
start.
If
you
did
equality,
compare
of
string,
question
mark
I
believe
you
could
leave
the
attributes
off
because.
A
Yeah
and
at
the
moment
it's
it's
even
worse
in
a
few
very
specific
cases
in
particular,
ie
quality
comparable
with
its
invariance
is
problematic
and
that's
currently
being
worked
on.
But
right
now
it's
the
one
place
in
our
code.
We
actually
use
pound
nullable
disabled
around
all
of
our
ie
quality,
comparable
implementations
for
reference
types
and
around
everywhere.
We
use
it
as
a
generic
constraint
because
of
issues
because.
A
C
A
C
E
A
F
And
and
I
mean
the
answer
really
there
is
that
if
you
create
a
string
string
to
bolt
right
fuse,
if
you
say
string
string
x,
equals
default
compatible
warning,
we
will
tell
you
the
trick
that
you
are
converting
that
the
type
of
string
questions
print
questions.
It's
not
matched,
that's
not
mastering
yeah.
C
Basically,
the
idea
in
temples
is
the
the
you
control
malleability
right.
If
you
say
okay
me
know
that
I
can't,
maybe
I
could
say,
cannot
be
nothing.
It
cannot
be
now
yeah.
The
case
here
is
that
it
doesn't
matter
what
you
said
he's
maybe
now,
because
he
specifically
assigned
base,
if
you
know
but
yeah
I.
A
A
Wait
handle
question
mark
and
then
how
to
maybe
no
on
the
getter
or
for
the
getter,
or
we
could
have
made
it
safe
way
to
handle
and
allowed
null
for
the
setter.
And
we
chose
this
because
it's
pretty
rare
to
use
the
setter
and
very
common
to
use
the
getter
comparatively
because
we
wanted
the
types
to
match
sort
of
that
intent.
C
G
No,
but
it
makes
at
least
Nelson
current
is
not
null
if
value
was
not.
B
C
C
F
F
E
F
F
A
I
C
E
A
C
E
I
H
A
F
F
E
Well,
they
couldn't
be
any
way
because
it's
generics,
so
the
the
non-generic
create
wrapper
of
type,
which
is
a
one
of
the
generic
one
calls
into
yeah.
Both
the
input.
Oh
and
the
return
our
question
mark
type
T
is,
does
not
have
a
question
mark.
There's
a
method
will
immediately
throw
out
there
to
you,
but
then
we
mean
that
created
a
prototype
would
also.
E
A
C
H
E
That
guarantee
yeah,
maybe
maybe
Jeremy,
would
be
the
best
person
to
that's,
but
I
am
looking
through
the
runtime
code
and
I
see
it
looks
like
it
prefers
to
throw
an
exception
rather
than
return
null.
But
talking
about
my
way.
B
E
C
E
You
I
don't
think
it
would
make
sense
to
ever
pass
a
struck
to
type
there,
because,
what's
going
to
happen,
is
the
value
that
you
pass
in
copy
front?
It's
going
to
be
boxed
and
then
you're
going
to
get
back
a
basically
a
Kong
pointer
to
the
object
that
is
now
boxed
that
you
don't
have
the
original
reference.
Well.
E
C
E
A
G
A
Than
constraining
because
constraining
to
not
to
call-
and
you
know
not
null
as
I-
think
Levi
or
you
know,
I
was
saying
you
know
it
does
mean
that
if
you
are
in
a
generic
context,
someone
else
is
getting
your
tea.
Now
you
have
to
deal
with
suppressing
warnings
from
that
not
having
been
constrained.
This
is
sort
of
the
most
permissive
all
still
achieving
what
we
want.
A
Even
for
some
existing
things
where
it
was
like
a
big
impact,
we
still
locked
over
the
constraint
like
dictionaries.
Tiki
is
constrained
to
not
know,
but
the
alternative
would
be
to
have
disallowed
null
everywhere.
Tiki
appears
yeah
and
that
doesn't
flow
well
through
some
of
the
resulting
kind
of
you
know
things
like
getting
the
enumerator
from
the
dictionary
and
stuff
like
that.
Those.
E
A
A
B
B
E
E
C
C
E
E
C
E
C
An
interesting
point
I
think
that
that
might
actually
be
not
a
bad
idea.
I
mean
it
I
guess
it
depends
on
what
you
optimizing
for
and
if
you
give,
if
you
have
a
spread
50-50
between
courts,
positives
and
false
negatives,
and
yes,
if
it's
more
like
80
percent,
is
correct
and
your
20%
false
positives,
and
maybe
that's
over
the
board
right
well,.
F
E
The
reason
I
bring
it
up
is
because
potentially
if
we
do
find
the
ability
to
expresses
in
the
future-
and
we
do
change
the
API
to
have
the
new
attribute
when
it
comes
up-
that
would
be
a
source
breaking
change,
correct
which
may
be
wrong
hailing.
It
just
wanted
us
to
make
sure
that,
yes,
we're
not
getting
into
a
corner
yeah.
C
C
C
F
F
A
A
I
A
F
F
F
C
A
F
H
B
A
F
C
More
philosophically
I
think
I
think
the
even
suggestion
makes
sense
if
all
usages
of
the
tea
in
the
class
would
accept
now
all
the
time
for
now
an
eternity
which
I'm
not
sure
as
the
problems
you
would
make
a
point.
It
makes
more
sense
to
me
to
say
where
t
:
class
and
then
just
put
the
question
marks
at
the
only
API
where
you
happen
to
support
nowadays,
which
today
might
be
everywhere
right.
But
is
that
true
for
like
for
eternity
and
is
that
the
promise
you
wanna
make.
C
A
There
are,
there
are
two
issues
here:
one
is
I
think
are
where
t
:
class
is
wrong,
because
you
just
look
at
the
public
API
like
it's
valid,
to
pass
null
yeah
to
everywhere,
and
the
public
API
surface
area
that
accepts
a
T
yeah.
Okay,
on
top
of
that,
Fred
is
saying,
and
Levi
is
saying
they
believe
that,
even
if
you
use
an
on
nullable
T,
you
should
be
able
to
pass
a
null
to
invocation
list
right,
I'm,
not
sure
I,
agree,
but
I
understand
what
they're
coming
from.
F
I,
don't
I
don't
feel
super
strongly
about
it.
I
just
I'm
wondering
whether
or
not
people
will
use
this
for
the
side
effect.
We
could
always
not
add
it
to
start
with,
and
then,
if
people
complain,
we
can
add
it.
What
I
don't
understand
is
like
what
kind
of
but
like.
Why
would
we
put
the
attitude
with
rather
than
putting
a
question
mark
on
the
teeth?
Well,
because
we're
saying
because
you
were
your
question
about,
do
we
guarantee
that
this
thing
will
always
accept
nulls.
G
Location
would
know
so
I'm,
saying
I'm,
saying
your
earlier
surf.
You
construe
the
last
question
mark
you
can
add
a
question
mark
to
the
tee,
but
even
if
you
can
spread
into
clouds,
you
can't
no,
you
can't.
If
you
can
straight
it's
a
class,
but
not
straight.
It's
classic
question
right.
So
what
I'm.
C
A
A
If
so,
so,
there's
there's
a
few
cases
here,
we
can
leave
it
at.
We
can
leave
it
as
it
currently
is
where
we
have,
where
t
:
class,
we
have
attributes
on
in
an
invocation
list
and
potentially
attributes
on
other
public
api's
that
accept
T.
If
we
don't
add
the
attributes
elsewhere,
then
currently
we're
Sybase
is
saying
no
is
not
accepted,
so
things
like
add
event
handler,
there's
the
option
of
changing
where
t
:
class
to
be
where
t
:
question
mark,
but
then
to
your
question
emo.
A
If
someone
constructed
that
with
a
non
nullable,
T,
Fred
and
levi's
argument,
as
you
still
use,
you
still
need
the
maybe
not
on
invocation
list,
even
where
T
is
constrained
to
class
question
mark,
because
we
might
still
return
null.
Even
if
someone
used
an
unknowable,
T
and
then
there's
the
third
option
which,
as
we
say
where
T
:
class
and
everywhere
we
use
T
in
the
public
API.
We
then
use
T
question
mark,
in
which
point
we
can
remove
the
attributes.
A
G
F
I
ever
use
attributes
because
perhaps
let
let's
say
the
original
definition
of
this
thing,
you
can
never
set
invocation
list
to
a
malleable
value,
but
it
starts
off
with
a
default.
That
is
normal
right.
There's,
no
way
to
express
that
this
has
different
in
and
Algerian
swith,
except
with
an
attribute
right.
If
I
give
you
if
it's--if
is
a
symmetric.
B
F
E
F
E
C
E
C
E
C
All
right,
so
then
this
is
that
we
have
10
minutes
left,
which
means
you
might
be
able
to
do.
10
more
files.
There
were
two
cookies
left.
I
pressed
my
whole
quitting
might
actually
succeed
in
Freddy.
C
A
C
E
A
E
A
E
E
I'm
I'm
a
little
confused
because
it
when
you
call
me
I,
don't
exchange
you're
generally
going
to
point
to
like
a
field
instead
of
a
local
variable,
something
like
that
which
means
at
the
time
exchange,
returns
and
says.
Yeah
I
said
a
dog
no
value
there
as
soon
as
you
try
to
dereference
it
in
the
line
immediately
thereafter,
it
could
be
no
again
so.
A
A
F
A
A
Are
multiple
overloads
here
that
fall
into
two
buckets
one
of
the
buckets
they
just
work
with
reference
types
and
are
typically
used
if
you're
just
initializing
some
reference
fields
from
not
from
null
to
nominal.
The
other
overloads
can
work
with
any
T,
struct
or
class
and
as
a
result,
since
they
can't
use.
You
know
whether
it's
null
or
not,
to
indicate
whether
it's
been
initialized
or
not.
H
F
E
That
actually
matter,
to
be
honest,
oh
just
about
matter,
because
generally
the
way
that
people
use
things
like
insurers
realized
is
this
Assam
ref
to
some
field
into
this
API,
which
Everly
tends
to
be
the
only
place
where
that
field
has
ever
used
inside
your
entire
code
names
generally.
What
you
do
is
you
call
it
sure,
initialized
read
the
return
value
and
then
use
that,
rather
than
looking
at
the
particular
case.
Maybe.
A
F
H
F
D
E
You
so
for
things
like
value,
factory
of
birth
or
api's,
without
initialized
or
a
sink
walk,
you
know
is
not
valid
from
a
usage
scenario,
because
I'm
sure
initialize
will
get
called
over
and
over
and
over
and
over
again,
so
just
yeah.
So
if,
if
you're
looking
at
this
overload
market
system
value
factory,
if
you,
if
this
value
country
memories
mailmouse
they're
going
so
if
this
value
factory
here
returns
old,
every
single
call
to
ensure
you.