You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@roji This is a struct, which means it always has an implicit parameterless constructor. It is this constructor that allows IsEmpty to return true. The parameterless constructor is (at least conceptually) called when the struct is used as a field, variable, etc. that is not explicitly initialized. We then use IsEmpty to check for this. If you create an explicit ValueBuffer for an array, then that array must not be null. So the array being null is a valid state for the ValueBuffer--it means it's the default instance. But setting the array to null in this constructor is not allowed.
Thanks @ajcvickers, makes sense. I'll leave _values annotated as non-nullable - as all accessors currently assume that they're never called with _values null - and suppress the warning in IsEmpty. In effect, the only thing you can do with the empty ValueBuffer is to check that it is the empty ValueBuffer.
We have an assertion in the ctor that this will never happen? What about _value.Length == 0?
(originally from #23423 (comment))
The text was updated successfully, but these errors were encountered: