-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.10.2
-
Component/s: None
-
None
This is my Warehouse class:
Unable to find source-code formatter for language: csharp. 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 Warehouse { public string Id { get; private set; } public string Name { get; private set; } public LocationAddress? Address { get; private set; } public WarehouseShelfSetting? ShelfSettings { get; private set; } public WarehouseTrolleySettings? TrolleySettings { get; private set; } public Warehouse(string name) { this.Name = name; this.Id = ObjectId.GenerateNewId().ToString(); } public Warehouse(string name, LocationAddress? address) { this.Name = name; this.Address = address; this.Id = ObjectId.GenerateNewId().ToString(); } public Warehouse(string id, string name, LocationAddress? address) { this.Name = name; this.Address = address; this.Id = id; } public class WarehouseTrolleySettings { public LabellingStrategy SlotLabelling { get; set; } public int NumberOfSlots { get; set; } } public class WarehouseShelfSetting { public LabellingStrategy ShelfLabelling { get; set; } public LabellingStrategy SlotLabelling { get; set; } } public enum LabellingStrategy { Alphabetic, Numeric } }
This is the document in the database:
{ "_id" : ObjectId("5c534452d3224cc69bdcb6ac"), "Name" : "Centrallagret", "Address" : { "StreetAddress" : "Storgatan 1", "StreetAddress2" : null, "PostalCode" : "123 45", "City" : "Stockholm", "CountryCode" : "se" } }
This code has been the same for very long time, but today I upgraded the MongoDB.Driver package, and now I get this exception:
System.FormatException: An error occurred while deserializing the Address property of class Zwiftly.Items.Warehouses.Warehouse: No matching creator found. ---> MongoDB.Bson.BsonSerializationException: No matching creator found. at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.ChooseBestCreator(Dictionary`2 values) at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.CreateInstanceUsingCreator(Dictionary`2 values) at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeClass(BsonDeserializationContext context) at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer serializer, BsonDeserializationContext context) at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeMemberValue(BsonDeserializationContext context, BsonMemberMap memberMap) --- End of inner exception stack trace --- at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeMemberValue(BsonDeserializationContext context, BsonMemberMap memberMap) at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeClass(BsonDeserializationContext context) at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize[TValue](IBsonSerializer`1 serializer, BsonDeserializationContext context) at MongoDB.Driver.Core.Operations.CursorBatchDeserializationHelper.DeserializeBatch[TDocument](RawBsonArray batch, IBsonSerializer`1 documentSerializer, MessageEncoderSettings messageEncoderSettings) at MongoDB.Driver.Core.Operations.FindCommandOperation`1.CreateCursorBatch(BsonDocument commandResult) at MongoDB.Driver.Core.Operations.FindCommandOperation`1.CreateCursor(IChannelSourceHandle channelSource, BsonDocument commandResult) at MongoDB.Driver.Core.Operations.FindCommandOperation`1.ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken) at MongoDB.Driver.IAsyncCursorSourceExtensions.FirstOrDefaultAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
I backed version by version and found that this regression was introduced in version 2.10.2.
- duplicates
-
CSHARP-3108 Deserialization throws No matching creator found exception
- Closed
- related to
-
CSHARP-2889 BsonClassMap.LookupClassMap supports private constructors inconsistently
- Closed
-
CSHARP-3845 Deserialize Select of anonymous types using default values for missing fields
- Closed