Closed
Description
I use alpha from master branch.
I Created JsonNetSerealizer with overrided protected override IList<Func<Type, JsonConverter>> ContractConverters => null;
But my ContractJsonConverter is not called.
I did some debugging and found that code in src\Nest\CommonAbstractions\SerializationBehavior\ElasticContractResolver.cs
protected override JsonContract CreateContract(Type objectType)
{
JsonContract contract = base.CreateContract(objectType);
// this will only be called once and then cached
if (typeof(IDictionary).IsAssignableFrom(objectType) && !typeof(IIsADictionary).IsAssignableFrom(objectType))
contract.Converter = new VerbatimDictionaryKeysJsonConverter();
else if (objectType == typeof(ServerError))
contract.Converter = new ServerErrorJsonConverter();
else if (objectType == typeof(DateTime) || objectType == typeof(DateTime?))
contract.Converter = new IsoDateTimeConverter();
else if (!objectType.FullName.StartsWith("Nest.", StringComparison.OrdinalIgnoreCase)) return contract;
else if (ApplyExactContractJsonAttribute(objectType, contract)) return contract;
else if (ApplyContractJsonAttribute(objectType, contract)) return contract;
if (this._contractConverters.HasAny())
{
foreach (var c in this._contractConverters)
{
var converter = c(objectType);
if (converter == null)
continue;
contract.Converter = converter;
break;
}
}
return contract;
}
Since my type name does not start from "Nest." it exits from function in case else if (!objectType.FullName.StartsWith("Nest.", StringComparison.OrdinalIgnoreCase)) return contract; . It does not check _contractConverters and uses the default one.
Can it be the bug?
Thank you a lot in advance!
Metadata
Metadata
Assignees
Labels
No labels