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

[BUG] Calling .ToString() on a BsonValue constructed from a string[] throws a NullReferenceException #2589

Open
Cryptoc1 opened this issue Feb 19, 2025 · 1 comment
Labels

Comments

@Cryptoc1
Copy link

Version
v5.0.21, on net9.0

Describe the bug
When constructing a BsonValue from an array of strings, calling .ToString() throws a NullReferenceException.

Code to Reproduce

var tags = ["hello", "world"];

var value = new BsonValue(tags);

// THROWS!
value.ToString();

Expected behavior
.ToString() should return the string representation of the array.

Screenshots/Stacktrace

An exception of type 'System.NullReferenceException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Object reference not set to an instance of an object.'
at LiteDB.JsonWriter.WriteArray(BsonArray arr)
at LiteDB.JsonWriter.WriteValue(BsonValue value)
at LiteDB.JsonSerializer.Serialize(BsonValue value, StringBuilder sb, Boolean indent)
at LiteDB.BsonValue.ToString()

...
<private code excluded>
@Cryptoc1 Cryptoc1 added the bug label Feb 19, 2025
@JKamsker
Copy link
Collaborator

Hello! Thank you for bringing this up!
What is the string representation you would expect here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants