Also fixed bug with indexer-property for `StandartResolver`.

This commit is contained in:
JoshuaLight 2017-10-03 15:14:32 -07:00
Родитель 7850de31cb
Коммит dacf87339d
4 изменённых файлов: 49 добавлений и 22 удалений

Просмотреть файл

@ -785,6 +785,26 @@ namespace SharedData
[Key(0)]
public string OPQ { get; set; }
}
[MessagePackObject]
public class WithIndexer
{
[Key(0)]
public int Data1 { get; set; }
[Key(1)]
public string Data2 { get; set; }
[Key(2)]
public int this[int i] { get { return 0; } }
}
public class WithIndexerContractless
{
public int Data1 { get; set; }
public string Data2 { get; set; }
public int this[int i] { get { return 0; } }
}
}
namespace Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad

Просмотреть файл

@ -1295,6 +1295,7 @@ typeof(int), typeof(int) });
{
if (item.GetCustomAttribute<IgnoreMemberAttribute>(true) != null) continue;
if (item.GetCustomAttribute<IgnoreDataMemberAttribute>(true) != null) continue;
if (item.IsIndexer()) continue;
var member = new EmittableMember
{

Просмотреть файл

@ -76,14 +76,6 @@ namespace MessagePack.Tests
public int OAFADFZEWFSDFSDFKSLJFWEFNWOZFUSEWWEFWEWFFFFFFFFFFFFFFZFEWBFOWUEGWHOUDGSOGUDSZNOFRWEUFWGOWHOGHWOG000000000000000000000000000000000000000HOGZ { get; set; }
}
public class HasIndexer
{
public int Data1 { get; set; }
public string Data2 { get; set; }
public int this[int i] { get { return 0; } }
}
[Fact]
public void SimpleTest()
{
@ -194,19 +186,5 @@ namespace MessagePack.Tests
v.IsStructuralEqual(o);
}
[Fact]
public void IndexerCheck()
{
var o = new HasIndexer
{
Data1 = 15,
Data2 = "15"
};
var bin = MessagePack.MessagePackSerializer.Serialize(o, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
var v = MessagePackSerializer.Deserialize<HasIndexer>(bin, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
v.IsStructuralEqual(o);
}
}
}

Просмотреть файл

@ -336,5 +336,33 @@ namespace MessagePack.Tests
re.MyProperty.Is(1000);
}
}
[Fact]
public void WithIndexer()
{
var o = new WithIndexer
{
Data1 = 15,
Data2 = "15"
};
var bin = MessagePack.MessagePackSerializer.Serialize(o, MessagePack.Resolvers.StandardResolver.Instance);
var v = MessagePackSerializer.Deserialize<WithIndexer>(bin, MessagePack.Resolvers.StandardResolver.Instance);
v.IsStructuralEqual(o);
}
[Fact]
public void WithIndexerContractless()
{
var o = new WithIndexerContractless
{
Data1 = 15,
Data2 = "15"
};
var bin = MessagePack.MessagePackSerializer.Serialize(o, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
var v = MessagePackSerializer.Deserialize<WithIndexerContractless>(bin, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
v.IsStructuralEqual(o);
}
}
}