Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-48

TimeSpan serialization not working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      in BsonWriter the if statement is missing an else and thus always falls through to the last else which tries to cast the timespan into a long

      case BsonType.Long:
      if(obj is TimeSpan)
      _writer.Write(((TimeSpan)obj).Ticks);
      if (obj is DateTime)
      Write((DateTime)obj);
      else
      _writer.Write((long)obj);
      return;

      should be

      case BsonType.Long:
      if(obj is TimeSpan)
      _writer.Write(((TimeSpan)obj).Ticks);
      else if (obj is DateTime)
      Write((DateTime)obj);
      else
      _writer.Write((long)obj);
      return;

        Attachments

          Activity

            People

            Assignee:
            lanwin Steve Wagner
            Reporter:
            matthiasg Matthias Goetzke
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: