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
Boxing of the value would occur only once. This would eliminate unnecessarily memory allocations in situations when GetValue is called many times. When method is used on a class types, copying would not occur and stored object would be returned instead.
One of the uses of GetValue method is User Interface based on MVVM (Model View Viewmodel) where values used to control an UI are pulled directly from the data. In realtime applications (like games) this boxing makes hundreds if not thousands of unnecessary memory allocations every second.
The text was updated successfully, but these errors were encountered:
A box-free way to do GetValue/SetValue would be an interesting addition to FieldInfo, but I wonder if adding T GetValue<T>(object) with a corresponding void SetValue<T>(object, T) wouldn't be a cleaner API surface to achieve that.
That said, this issue is unlikely to get traction in the CoreCLR repo - API addition proposals should follow the API review process and get filed in the CoreFX repo - that's where the community discusses API additions to .NET.
This new method would accept an "object" to which a Value could be copied instead of being unnecessarily boxed. Example of use would look like this:
Boxing of the value would occur only once. This would eliminate unnecessarily memory allocations in situations when GetValue is called many times. When method is used on a class types, copying would not occur and stored object would be returned instead.
One of the uses of GetValue method is User Interface based on MVVM (Model View Viewmodel) where values used to control an UI are pulled directly from the data. In realtime applications (like games) this boxing makes hundreds if not thousands of unnecessary memory allocations every second.
The text was updated successfully, but these errors were encountered: