Ronald Laeremans [MSFT] wrote:
Some additional background:
The restriction of it needing to be in the same assembly of the
current rule is because we do not read metadata for private members,
and so a ref type could be hiding there.
And the restriction of needing sequential or explicit layout is
because the CLR decision to have all value types have sequential
layout by default came pretty late in the 7.0 cycle. We didn't
consider any of this important enough to revisit for 7.1.
Why does a restriction also apply to variables of __value enum
embedded in __nogc types ? Clearly these follow neither the first
explanation above, about hidden ref types nor the second about
sequential layout. Yet if I try to embed a __value enum variable in
a __nogc class the compiler gives me an error saying that I can not
do it.
Ronald
Hi Edward,
I can understand the rule against having any ref types but I don't
understand the simplifying choice.
I think he might've meant simplifying it for the compiler
development, not necessarily the end user
It ain't exactly all that trivial to check, since the check would
need to be recursive (remember Ronald pointed out it applied to
direct _and_ indirect containment of handles to managed ref types),
so there are a few ugly cases that would need to be cared for,
making things more complex than necessary.
Then again, it's just mho, I might be just missing the point