mongodb/mongo-csharp-driver — pull request #121 by optimiz3 (2012-07-28 23:05:26+00:00)
Title: Fix CSHAP-541: Make BsonClassMap<TClass>.MapMember Typesafe

Fix for CSHAP-541: Make BsonClassMap.MapMember Typesafe

- Added a strongly typed BsonMemberMap
- Made MapMember variants return a strongly typed BsonMemberMap
- This made it simpler to write member mapping code
- Before: BsonClassMap.RegisterClassMap(classMap => { classMap.AutoMap(); classMap.MapMember(myType => myType.MyField).SetShouldSerializeMethod(obj => !((MyType)obj).MyField != null); });
- After: BsonClassMap.RegisterClassMap(classMap => { classMap.AutoMap(); classMap.MapMember(myType => myType.MyField).SetShouldSerializeMethod(myType => myType.MyField != null); });
- Deprecated MapField, MapProperty, MapIdField, MapIdProperty, MapExtraElementsField, MapExtraElementsProperty, UnmapField, and UnmapProperty
- In .Net it is forbidden to have have a property and field with the same name; having both *Field and *Property versions when the API was capable of determining what to do needlessly complicated the API.
- The lambda versions were semantically incorrect as they were calling MapMember, which does not distinguish between fields and properties.
- All of this code was refactored to a few small versions, which reduced bloat (for example, all versions called MapMember, which performs argument validation and freeze checking).
- Fixed a small validation bug in SetSerializeDefaultValue