Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for initializing array types in constructrow #25

Merged

Conversation

KalopsiaTwilight
Copy link
Contributor

@KalopsiaTwilight KalopsiaTwilight commented Aug 15, 2024

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.

@Marlamin Marlamin merged commit 82e6da0 into wowdev:master Aug 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants