mbdavid / LiteDB

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

[BUG]Custom BsonMapper not work corrently #1977

Open humhei opened 3 years ago

humhei commented 3 years ago

Version LiteDB 5.0.10

Describe the bug

    public class MyBsonMapper : BsonMapper
    {

        public override object ToObject(Type type, BsonDocument doc)
        {
            /// this code never get invoked
            throw new NotSupportedException();
        }

        public override T ToObject<T>(BsonDocument doc)
        {
            /// this code never get invoked
            throw new NotSupportedException();
        }

    }

ToObject Never get invoked

Code to Reproduce https://github.com/humhei/LiteDBCustomBsonMapper

Expected behavior ToObject get invoked

Screenshots/Stacktrace image Exit with 0, exception should threw but here not

Amleto commented 3 years ago

If this previously worked, then it seems it is 'disconnected' now. Suggest you add custom serializers - use RegisterType<T>(...)