Details
-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
2.3.1
-
None
Description
From https://github.com/couchbaselabs/Linq2Couchbase/issues/150
If possible, it should fallback to the default contract resolver behavior used by Json.Net if no specific contract resolver is defined. If this isn't possible, then we should throw a more meaningful exception in GetMemberName.
Message from issue #150:
Assuming this code:
var config = new ClientConfiguration(); |
var jsonSettings = new JsonSerializerSettings |
{
|
Binder = SerializationBinder,
|
TypeNameHandling = TypeNameHandling.All,
|
};
|
config.Serializer = () => new DefaultSerializer(jsonSettings, jsonSettings); |
var cluster = new Cluster(config); |
var bucket = cluster.OpenBucket("MyBucket"); |
var context = new BucketContext(bucket); |
Queries will fail at this line:
//ExtendedTypeSerializerMemberNameResolver.cs |
|
public bool TryResolveMemberName(MemberInfo member, out string memberName) |
{
|
memberName = null; |
|
if (member == null) |
return false; |
|
memberName = _serializer.GetMemberName(member); //BOOM, here |
|
return memberName != null; |
}
|
By setting a ContractResolver = new CamelCasePropertyNamesContractResolver() on the json settings, this problem is resolved.
The BucketContext should probably throw if the client configuration does not provide the above.
Attachments
Issue Links
- duplicates
-
NCBC-1157 Queries fail if DefaultSerializer.ContractResolver is null
- Resolved