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

Enums with underlying value as 0 does not save

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.12.3
    • Component/s: Serialization
    • Labels:
      None

      When I use the IgnoreIfDefaultConvention, enums that starts at 0 does not save the first element of the enum. When I change the starting number to 1, it starts saving again normally. I think that when it goes to check the convention, it checks the number and mark as default because integers default is 0 in C#, and the convention make the driver ignore it, but it is wrong because it's not a default value for Enum, it has a value, it's just the underlying value that is the same as the default for integer.

       

      Example
      public enum LogType
      {
      Info, // Doesn't save the first element
      Warning,
      Error
      }

      public class Model()

      { public LogType Type \{ get; set; }

      }
       

       

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            tecnologia@rissicontabilidade.com.br João Vitor Pina
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: