@@ -48,6 +48,39 @@ public class SimpleTestClass
48
48
public virtual int Id { get ; set ; }
49
49
}
50
50
51
+ [ Serializable ]
52
+ public class RefOutTestClass
53
+ {
54
+ public virtual int Id { get ; set ; }
55
+
56
+ public virtual void Method1 ( out int x )
57
+ {
58
+ x = 3 ;
59
+ }
60
+
61
+ public virtual void Method2 ( ref int x )
62
+ {
63
+ x ++ ;
64
+ }
65
+
66
+ public virtual void Method3 ( out int ? y )
67
+ {
68
+ y = 4 ;
69
+ }
70
+
71
+ public virtual void Method4 ( ref int ? y )
72
+ {
73
+ y ++ ;
74
+ }
75
+
76
+ public virtual void Method ( ref Dictionary < string , string > dictionary )
77
+ {
78
+ dictionary = dictionary == null
79
+ ? new Dictionary < string , string > ( )
80
+ : new Dictionary < string , string > ( dictionary ) ;
81
+ }
82
+ }
83
+
51
84
[ Serializable ]
52
85
public class CustomSerializationClass : ISerializable
53
86
{
@@ -141,6 +174,51 @@ public void VerifyProxyForClassWithAdditionalInterface()
141
174
#endif
142
175
}
143
176
177
+ [ Test ]
178
+ public void VerifyProxyForRefOutClass ( )
179
+ {
180
+ var factory = new StaticProxyFactory ( ) ;
181
+ factory . PostInstantiate (
182
+ typeof ( RefOutTestClass ) . FullName ,
183
+ typeof ( RefOutTestClass ) ,
184
+ new HashSet < System . Type > { typeof ( INHibernateProxy ) } ,
185
+ null ,
186
+ null ,
187
+ null ) ;
188
+
189
+ #if NETFX
190
+ VerifyGeneratedAssembly (
191
+ ( ) =>
192
+ {
193
+ #endif
194
+ var proxy = factory . GetProxy ( 1 , null ) ;
195
+ Assert . That ( proxy , Is . Not . Null ) ;
196
+
197
+ var state = new RefOutTestClass ( ) ;
198
+ proxy . HibernateLazyInitializer . SetImplementation ( state ) ;
199
+
200
+ var entity = ( RefOutTestClass ) proxy ;
201
+ entity . Method1 ( out var x ) ;
202
+ Assert . That ( x , Is . EqualTo ( 3 ) ) ;
203
+
204
+ entity . Method2 ( ref x ) ;
205
+ Assert . That ( x , Is . EqualTo ( 4 ) ) ;
206
+
207
+ entity . Method3 ( out var y ) ;
208
+ Assert . That ( y , Is . EqualTo ( 4 ) ) ;
209
+
210
+ entity . Method4 ( ref y ) ;
211
+ Assert . That ( y , Is . EqualTo ( 5 ) ) ;
212
+
213
+ var dictionary = new Dictionary < string , string > ( ) ;
214
+ var param = dictionary ;
215
+ entity . Method ( ref param ) ;
216
+ Assert . That ( param , Is . Not . SameAs ( dictionary ) ) ;
217
+ #if NETFX
218
+ } ) ;
219
+ #endif
220
+ }
221
+
144
222
[ Test ]
145
223
public void InitializedProxyStaysInitializedAfterDeserialization ( )
146
224
{
0 commit comments