@@ -90,12 +90,13 @@ private void AddDeepConstructor(TypeDefinition type)
9090
9191 Func < TypeReference , IEnumerable < Instruction > > baseCopyFunc = null ;
9292
93- if ( type . BaseType . Resolve ( ) . MetadataToken == TypeSystem . ObjectDefinition . MetadataToken )
93+ var baseElementType = type . BaseType . GetElementType ( ) . Resolve ( ) ;
94+ if ( IsType ( baseElementType , typeof ( object ) ) )
9495 {
9596 processor . Emit ( OpCodes . Ldarg_0 ) ;
96- processor . Emit ( OpCodes . Call , ImportDefaultConstructor ( TypeSystem . ObjectDefinition ) ) ;
97+ processor . Emit ( OpCodes . Call , ImportDefaultConstructor ( ImportType ( typeof ( object ) ) ) ) ;
9798 }
98- else if ( IsType ( type . BaseType . GetElementType ( ) . Resolve ( ) , typeof ( ValueType ) ) )
99+ else if ( IsType ( baseElementType , typeof ( ValueType ) ) )
99100 {
100101 // nothing to do here
101102 }
@@ -105,19 +106,19 @@ private void AddDeepConstructor(TypeDefinition type)
105106 processor . Emit ( OpCodes . Ldarg_1 ) ;
106107 processor . Emit ( OpCodes . Call , baseConstructor ) ;
107108 }
108- else if ( IsType ( type . BaseType . GetElementType ( ) . Resolve ( ) , typeof ( Dictionary < , > ) ) )
109+ else if ( IsType ( baseElementType , typeof ( Dictionary < , > ) ) )
109110 {
110111 processor . Emit ( OpCodes . Ldarg_0 ) ;
111112 processor . Emit ( OpCodes . Call , ImportDefaultConstructor ( type . BaseType ) ) ;
112113 baseCopyFunc = reference => CopyDictionary ( reference , ValueSource . New ( ) , ValueTarget . New ( ) ) ;
113114 }
114- else if ( IsType ( type . BaseType . GetElementType ( ) . Resolve ( ) , typeof ( List < > ) ) )
115+ else if ( IsType ( baseElementType , typeof ( List < > ) ) )
115116 {
116117 processor . Emit ( OpCodes . Ldarg_0 ) ;
117118 processor . Emit ( OpCodes . Call , ImportDefaultConstructor ( type . BaseType ) ) ;
118119 baseCopyFunc = reference => CopyList ( reference , ValueSource . New ( ) , ValueTarget . New ( ) ) ;
119120 }
120- else if ( IsType ( type . BaseType . GetElementType ( ) . Resolve ( ) , typeof ( HashSet < > ) ) )
121+ else if ( IsType ( baseElementType , typeof ( HashSet < > ) ) )
121122 {
122123 processor . Emit ( OpCodes . Ldarg_0 ) ;
123124 processor . Emit ( OpCodes . Call , ImportDefaultConstructor ( type . BaseType ) ) ;
0 commit comments