File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ public void BoxUnbox()
88 {
99 var obj = ( BoxedValue < int > ) 42 ;
1010 // Assert.AreEqual(42.GetHashCode(), obj.GetHashCode());
11- Assert . AreEqual ( 42 , obj . Value ) ;
11+ Assert . AreEqual ( 42 , obj . GetReference ( ) ) ;
1212 // Assert.AreEqual(42, (int)obj);
1313 // Assert.AreEqual(typeof(int), obj.GetType());
1414 }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ namespace DotNext.Runtime;
2424public class BoxedValue < T > // do not add any interfaces or base types
2525 where T : struct
2626{
27- private T value ;
27+ internal T value ;
2828
2929 static BoxedValue ( )
3030 {
@@ -119,4 +119,11 @@ private BoxedValue()
119119 /// <returns>Mutable reference to the boxed value.</returns>
120120 public static implicit operator ValueReference < T > ( BoxedValue < T > boxedValue )
121121 => new ( boxedValue , ref boxedValue . value ) ;
122+ }
123+
124+ public static class BoxedValue
125+ {
126+ public static ref T GetReference < T > ( this BoxedValue < T > boxedValue )
127+ where T : struct
128+ => ref boxedValue . value ;
122129}
You can’t perform that action at this time.
0 commit comments