mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.52k stars 1.24k forks source link

[QUESTION] full support for c# record types #2374

Closed mhejle closed 3 months ago

mhejle commented 12 months ago

Hi @mbdavid et al.

Is there any plan to fully support c# record types. I.e only having a primary ctor and not having any explicit properties.

Like this, public record MyRecord(int Count, MyNestedObject Content);

Alternatively with an explicit ctor like this

public record MyRecord { public MyRecord(int Count, MyNestedObject Content) { this.Count = Count; this.Content = Content; }

public int Count { get; }
public MyNestedObject Content { get; }

}

Being forced to have an empty ctor really does not play well with <Nullable>enable</Nullable>

Serializing them works nicely, and i get a valid and complete json document in the database, but deserializing fails.

This question was closed, without any clear answer to the question. https://github.com/mbdavid/LiteDB/issues/2044

alexbereznikov commented 11 months ago

I think required can be used as a workaround

athendrix commented 10 months ago

I added a pull request here that adds full support for C# record types. https://github.com/mbdavid/LiteDB/pull/2384

JKamsker commented 3 months ago

The related pr has been merged long ago. I assume it has been fixed now. Reopen the issue if it persists.