File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,25 @@ namespace DotNext.Runtime;
2424public class BoxedValue < T > // do not add any interfaces or base types
2525 where T : struct
2626{
27+ private T value ;
28+
29+ static BoxedValue ( )
30+ {
31+ // AOT: instantiate the class to make instance members visible to AOT
32+ var boxed = new BoxedValue < T > ( ) ;
33+ GC . KeepAlive ( boxed ) ;
34+ }
35+
2736 [ ExcludeFromCodeCoverage ]
28- private BoxedValue ( ) => throw new NotImplementedException ( ) ;
37+ private BoxedValue ( )
38+ {
39+ }
2940
3041 /// <summary>
3142 /// Gets a reference to the boxed value.
3243 /// </summary>
3344 [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
34- public ref T Value => ref Unsafe . Unbox < T > ( this ) ;
45+ public ref T Value => ref value ;
3546
3647 /// <summary>
3748 /// Converts untyped reference to a boxed value into a typed reference.
You can’t perform that action at this time.
0 commit comments