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

Enums with underlying value as 0 does not save

    XMLWordPrintable

    Details

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

      Description

      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; }

      }
       

       

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: