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

Make BsonClassMap<TClass>.MapMember Typesafe

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.5
    • Component/s: Serialization
    • Labels:
      None
    • Environment:
      All

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

      );

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

              Created:
              Updated:
              Resolved: