Add support for initializing array types in constructrow #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the current version of DBCD, constructing a new row and adding it to a storage works perfectly fine for types that consist only of base types that get initialized with their defaults such as in AlliedRace.db2. However for dynamic types that have an array or string types, such as in the ItemDisplayInfo.db2, these types get initialized to null by C#'s default. This results in a null reference upon writing unless they are properly initialized by the consumer.
This PR adds the initialization code for an array and string type into the ConstructRow() call, so that a consumer does not need to worry about proper initialization and can use the new row as they would any row that was read from a parser.
I have added two tests to showcase what this PR fixes. The first test 'TestWritingNewRowDb2' adds a constructed row to a simple db2, and passes in the current version of DBCD. The second test 'TestWritingNewRowDb2WithArrayField' fails without the initialization code with a null reference exception.