Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when serializing generic property #119

Closed
KingTopas opened this issue Sep 29, 2015 · 4 comments
Closed

Exception when serializing generic property #119

KingTopas opened this issue Sep 29, 2015 · 4 comments
Labels
bug Detected as bug

Comments

@KingTopas
Copy link

Two classes:

public abstract class A
{
public virtual TId Id { get; set; }
}

public class B : A:
{
}

An exception is thrown when creating serializer for an instance of class B:

Void set_Id method (Int32) can not be solved because the declarative type descriptor methods A`1 [tid] is generic. Explicitly specify the type of declaration GetMethodFromHandle.

System.Reflection.MethodBase.GetMethodFromHandle(RuntimeMethodHandle handle) +11045317
MsgPack.Serialization.EmittingSerializers.FieldBasedSerializerEmitter.CreateConstructor() in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\EmittingSerializers\FieldBasedSerializerEmitter.cs:448
MsgPack.Serialization.EmittingSerializers.SerializerEmitter.CreateInstance(SerializationContext context, PolymorphismSchema schema) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\EmittingSerializers\SerializerEmitter.cs:130
MsgPack.Serialization.EmittingSerializers.<>c__DisplayClass6f.b__6e(SerializationContext context) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\EmittingSerializers\ILEmittingSerializerBuilder2.cs:1028 MsgPack.Serialization.AbstractSerializers.SerializerBuilder3.BuildSerializerInstance(SerializationContext context, Type concreteType, PolymorphismSchema schema) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\AbstractSerializers\SerializerBuilder`3.cs:201
MsgPack.Serialization.MessagePackSerializer.CreateInternal(SerializationContext context, PolymorphismSchema schema) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\MessagePackSerializer.cs:308
MsgPack.Serialization.SerializationContext.GetSerializer(Object providerParameter) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\SerializationContext.cs:691
MsgPack.Serialization.MessagePackSerializer.Get(SerializationContext context, Object providerParameter) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\MessagePackSerializer.cs:209
MsgPack.Serialization.MessagePackSerializer.Create(SerializationContext context) in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\MessagePackSerializer.cs:106
MsgPack.Serialization.MessagePackSerializer.Create() in d:\build\msgpack-cli-latest\src\MsgPack\Serialization\MessagePackSerializer.cs:80

@KingTopas
Copy link
Author

Seems the editor can't handle tags...

public abstract class A<TId>
{
public virtual TId Id { get; set; }
}

public class B : A<int>
{
}

@yfakariya
Copy link
Member

I could not reproduce this, but if the Id property setter was NOT public it looked liked to be reproduced. Was the Id property public? If so, it was bug and I'll fix it.

@KingTopas
Copy link
Author

Yes, sorry for noc mentioning it earlier. The whole declaration of Id is:

public virtual TId Id
{
get;
internal set;
}

@yfakariya
Copy link
Member

OK, thank you. I'll fix it.

@yfakariya yfakariya added the bug Detected as bug label Oct 8, 2015
yfakariya added a commit that referenced this issue Oct 12, 2015
…mbers which use generic type parameter(s). Issue #119

This commit adds storing MethodBase/FieldInfo together with existing code-gen related info. It solves field/method resolution failure for generic ones. In addition, this commit adds unit tests for issue 119.
yfakariya added a commit that referenced this issue Oct 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Detected as bug
Projects
None yet
Development

No branches or pull requests

2 participants