Ignore name on GetCurrentBsonType()

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.6.0
    • Component/s: Serialization
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have been getting an issue with regards to the GetCurrentBsonType() method. 
      I have looked around but the only fix I have come across is to skip the name as in the VerifyBsonType() method.

      My situation for some context:

      I read a value and then proceed to a custom serializer 
      1) read start document
      2) read string
      3) get current type

      Doing this results in an exception thrown by

      if (_state != BsonReaderState.Value)
       {
       ThrowInvalidState("GetCurrentBsonType", BsonReaderState.Value);
       }

      as _state is name.

      However, if I change my operations to 

      1) read start document
      2) read string
      3) read name
      4) get current type

      I get another exception when the value to be deserialized is in an array - where there is no name.

      My proposed solution is to add

      if(_state == BsonReaderState.Name)
       {
       SkipName();
       }

      before the state check as in the VerifyBsonType() method.

            Assignee:
            Unassigned
            Reporter:
            Vyacheslav
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: