Please make sizeof(T) compatible with uint/nuint #5399
Replies: 5 comments 7 replies
-
Please, yes. This is such a common stone in my shoe, more than ever now that https://github.com/microsoft/CsWin32 (the new official vehicle for Windows APIs) follows the metadata and generates every |
Beta Was this translation helpful? Give feedback.
-
Yep, I hit this regularly in my own code and its always frustrating that there isn't a general concept of "non negative signed integer". .NET, throughout the entire ecosystem, takes in This would help avoid bugs and address correctness issues, like
It could also allow implicit conversion from |
Beta Was this translation helpful? Give feedback.
-
It seems like we could just define a constant value conversion the same way we do for integer literals. |
Beta Was this translation helpful? Give feedback.
-
Yeah, implicit conversion on A lot of my interop codebases but also bunch of serialization classes that deals with |
Beta Was this translation helpful? Give feedback.
-
I'm curious if it's possible to ditch |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing lots of interop code these days, and I constantly have to add all these casts for things like
And even the new
NativeMemory
requires me to do this because it takes anuint
,sizeof()
is a const expression that will never be negative, so I feel like the casting should really be unnecessary / implicit, like it is if I assign a non-negativeconst int
to auint
.I know @tannergooding and @Sergio0694 will back me up on this :)
Beta Was this translation helpful? Give feedback.
All reactions