@@ -17,7 +17,6 @@ public sealed class FieldInterceptorObjectReference : IObjectReference, ISeriali
1717 private readonly object _deserializedProxy ;
1818
1919 private const string HasAdditionalDataName = "proxy$hasAdditionalData" ;
20- private const string AdditionalMemberName = "proxy$additionalMembers" ;
2120
2221 public FieldInterceptorObjectReference ( NHibernateProxyFactoryInfo proxyFactoryInfo , IFieldInterceptor fieldInterceptorField )
2322 {
@@ -30,39 +29,36 @@ private FieldInterceptorObjectReference(SerializationInfo info, StreamingContext
3029 _proxyFactoryInfo = info . GetValue < NHibernateProxyFactoryInfo > ( nameof ( _proxyFactoryInfo ) ) ;
3130 _fieldInterceptor = info . GetValue < IFieldInterceptor > ( nameof ( _fieldInterceptor ) ) ;
3231
32+ var proxy = _proxyFactoryInfo . CreateProxyFactory ( ) . GetFieldInterceptionProxy ( null ) ;
3333 if ( info . GetBoolean ( HasAdditionalDataName ) )
3434 {
35- _deserializedProxy = _proxyFactoryInfo . CreateProxyFactory ( ) . GetFieldInterceptionProxy ( null ) ;
36-
37- var additionalMembers = info . GetValue < MemberInfo [ ] > ( AdditionalMemberName ) ;
38- if ( additionalMembers == null )
39- return ;
40-
41- foreach ( var member in additionalMembers )
35+ var members = FormatterServices . GetSerializableMembers ( _proxyFactoryInfo . PersistentClass , context ) ;
36+ foreach ( var member in members )
4237 {
4338 switch ( member )
4439 {
4540 case FieldInfo field :
4641 field . SetValue (
47- _deserializedProxy ,
42+ proxy ,
4843 info . GetValue ( GetAdditionalMemberName ( field ) , field . FieldType ) ) ;
4944 break ;
5045 case PropertyInfo property :
5146 property . SetValue (
52- _deserializedProxy ,
47+ proxy ,
5348 info . GetValue ( GetAdditionalMemberName ( property ) , property . PropertyType ) ) ;
5449 break ;
5550 default :
5651 throw new NotSupportedException (
5752 $ "Deserializing a member of type { member . GetType ( ) } is not supported.") ;
5853 }
5954 }
55+ _deserializedProxy = proxy ;
6056 }
6157 else
6258 {
6359 // Base type has a custom serialization, we need to call the proxy deserialization for deserializing
6460 // base type members too.
65- var proxyType = _proxyFactoryInfo . CreateProxyFactory ( ) . GetFieldInterceptionProxy ( null ) . GetType ( ) ;
61+ var proxyType = proxy . GetType ( ) ;
6662 var deserializationConstructor = proxyType . GetConstructor (
6763 BindingFlags . Instance | BindingFlags . NonPublic | BindingFlags . Public ,
6864 null ,
@@ -95,8 +91,6 @@ public void GetBaseData(SerializationInfo info, StreamingContext context, object
9591 info . AddValue ( HasAdditionalDataName , true ) ;
9692
9793 var members = FormatterServices . GetSerializableMembers ( proxyBaseType , context ) ;
98- info . AddValue ( AdditionalMemberName , members ) ;
99-
10094 foreach ( var member in members )
10195 {
10296 switch ( member )
0 commit comments