File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,21 @@ public void TestWritingNewRowDb2WithArrayField()
6666 Assert . AreEqual ( 116146 , outputStorage . Count ) ;
6767 }
6868
69+ [ TestMethod ]
70+ public void TestWritingNewRowDb2WithArrayOfStringsField ( )
71+ {
72+ DBCD dbcd = new ( wagoDBCProvider , githubDBDProvider ) ;
73+ IDBCDStorage storage = dbcd . Load ( "BattlePetEffectProperties" , "9.2.7.45745" ) ;
74+
75+ storage . Add ( 10 , storage . ConstructRow ( 10 ) ) ;
76+ storage . Save ( Path . Join ( OutputPath , "BattlePetEffectProperties.db2" ) ) ;
77+
78+ DBCD localDbcd = new ( new FilesystemDBCProvider ( OutputPath ) , githubDBDProvider ) ;
79+ IDBCDStorage outputStorage = localDbcd . Load ( "BattlePetEffectProperties" , "9.2.7.45745" ) ;
80+
81+ Assert . AreEqual ( 134 , outputStorage . Count ) ;
82+ }
83+
6984 [ TestMethod ]
7085 public void TestSavingSameStorageTwice ( )
7186 {
Original file line number Diff line number Diff line change @@ -204,10 +204,19 @@ public DBCDRow ConstructRow(int index)
204204 foreach ( var arrayField in arrayFields )
205205 {
206206 var count = arrayField . GetCustomAttribute < CardinalityAttribute > ( ) . Count ;
207- Array rowRecords = Array . CreateInstance ( arrayField . FieldType . GetElementType ( ) , count ) ;
207+ var elementType = arrayField . FieldType . GetElementType ( ) ;
208+ var isStringField = elementType == typeof ( string ) ;
209+
210+ Array rowRecords = Array . CreateInstance ( elementType , count ) ;
208211 for ( var i = 0 ; i < count ; i ++ )
209212 {
210- rowRecords . SetValue ( Activator . CreateInstance ( arrayField . FieldType . GetElementType ( ) ) , i ) ;
213+ if ( isStringField )
214+ {
215+ rowRecords . SetValue ( string . Empty , i ) ;
216+ } else
217+ {
218+ rowRecords . SetValue ( Activator . CreateInstance ( elementType ) , i ) ;
219+ }
211220 }
212221 arrayField . SetValue ( raw , rowRecords ) ;
213222 }
You can’t perform that action at this time.
0 commit comments