-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.11.6
-
Component/s: BSON
-
None
-
Environment:Windows 10 Pro
The following simple class should be able to serialize and deserialize to the database without modification.
Unable to find source-code formatter for language: cs. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
public class Sample { public Sample(DateTime dateTime, double value) { DateTime = dateTime; Value = value; } public DayOfWeek Day => DateTime.DayOfWeek; public int Hour => DateTime.TimeOfDay.Hours; public DateTime DateTime { get; } public double Value { get; } }
It is very clear the intent of this class. We have tried using [BsonConstructor] with no success either. We shouldn't be forced to use private setters to make this work. Private setters are very different than readonly setters, in both cases serialization and deserialization should just work.
- duplicates
-
CSHARP-3240 ImmutableTypeClassMapConvention is ignoring some constructors
- Closed