CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.8k stars 277 forks source link

Fast unboxing of Box<T> value without unnecessary type checking #823

Closed AlexRadch closed 5 months ago

AlexRadch commented 5 months ago

Closes #822

PR Checklist

Sergio0694 commented 5 months ago

The code being introduced relies on undefined behavior and is not safe. The whole type really is doing that too, which is why I plan on removing it altogether. There is no safe way of unboxing a boxed value bypassing type checks as of now, and relying on runtime internals is not the right approach. I also somehow missed marking this type as obsolete in the past 8.x release 😅