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

Make BsonClassMap<TClass>.MapMember Typesafe

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • 1.5
    • Serialization
    • None
    • All

    Description

      Right now the BsonClassMap<TClass>.MapMember functionality is cumbersome because the returned type is of type BsonMemberMap rather than BsonMemberMap<TMember>. This forces the user to always recast when dealing with various BsonMemberMap Set methods.

      This is error prone, overly verbose, and violates the design principle of forcing the caller reprovide information that has already been specified.

      Consider the current situation:

      BsonClassMap.RegisterClassMap<MyType>(classMap =>

      { classMap.AutoMap(); classMap.MapMember(myType => myType.MyField) .SetShouldSerializeMethod(obj => !((MyType)obj).MyField != null); }

      );

      Instead it really should be:

      BsonClassMap.RegisterClassMap<MyType>(classMap =>

      { classMap.AutoMap(); classMap.MapMember(myType => myType.MyField) .SetShouldSerializeMethod(myType => myType.MyField != null); }

      );

      Attachments

        Activity

          People

            Unassigned Unassigned
            optimiz3 Alexander Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: