File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,10 @@ public class Test
4444
4545 private readonly object y = new object ( ) ;
4646
47+ // this field to make class unsafe and readonly
48+ #pragma warning disable 169
4749 private readonly UnsafeStructTest z ;
50+ #pragma warning restore 169
4851
4952 public object GetY ( )
5053 {
Original file line number Diff line number Diff line change @@ -203,7 +203,11 @@ public sealed class C6
203203
204204 private readonly object y = new object ( ) ;
205205
206+ // it is struct - and it can't be null, but it's readonly and should be copied
207+ // also it private to ensure it copied correctly
208+ #pragma warning disable 169
206209 private readonly StructWithObject z ;
210+ #pragma warning restore 169
207211
208212 public object GetY ( )
209213 {
@@ -225,6 +229,7 @@ public void Object_With_Readonly_Fields_Should_Be_Cloned()
225229 Assert . That ( clone . X , Is . EqualTo ( 1 ) ) ;
226230 Assert . That ( clone . GetY ( ) , Is . Not . Null ) ;
227231 Assert . That ( clone . GetY ( ) , Is . Not . EqualTo ( c . GetY ( ) ) ) ;
232+ Assert . That ( clone . GetY ( ) , Is . Not . EqualTo ( c . GetY ( ) ) ) ;
228233 }
229234
230235 public class VirtualClass1
You can’t perform that action at this time.
0 commit comments