C# 固定和#x27;过时';使用MsgPack.Cli时出现警告
我正在使用MsgPack.Cli为我创建的会话类编写自定义序列化程序。使用创建类后,我收到以下警告: 警告:“MessagePackSerializer.MessagePackSerializer()”已过时:“请改用MessagePackSerializer(序列化上下文)。” 我无法确定什么样的更改可以修复此警告。我不认为有必要了解MessagePackSerializer来帮助我解决这个问题;我根本不明白警告的语法 我的代码包括在下面:C# 固定和#x27;过时';使用MsgPack.Cli时出现警告,c#,.net,compiler-warnings,msgpack,C#,.net,Compiler Warnings,Msgpack,我正在使用MsgPack.Cli为我创建的会话类编写自定义序列化程序。使用创建类后,我收到以下警告: 警告:“MessagePackSerializer.MessagePackSerializer()”已过时:“请改用MessagePackSerializer(序列化上下文)。” 我无法确定什么样的更改可以修复此警告。我不认为有必要了解MessagePackSerializer来帮助我解决这个问题;我根本不明白警告的语法 我的代码包括在下面: namespace Something_Networ
namespace Something_Networky
{
public class Session
{
private int _n;
public int n { get; }
public Session(int n)
{
this._n = n;
}
}
public class SessionSerializer : MessagePackSerializer<Session>
{
public SessionSerializer() : this(SerializationContext.Default) { }
public SessionSerializer(SerializationContext context) // Warning displayed on this line
{
}
protected override void PackToCore(Packer packer, Session value)
{
throw new NotImplementedException();
}
protected override Session UnpackFromCore(Unpacker unpacker)
{
throw new NotImplementedException();
}
}
}
namespace某物\u网络
{
公开课
{
私人国际;
公共整数n{get;}
公开会议(int n)
{
这个;
}
}
公共类SessionSerializer:MessagePackSerializer
{
public SessionSerializer():此(SerializationContext.Default){}
public SessionSerializer(SerializationContext)//此行显示警告
{
}
受保护的覆盖无效PackToCore(封隔器封隔器,会话值)
{
抛出新的NotImplementedException();
}
受保护的覆盖会话解包核心(解包解包)
{
抛出新的NotImplementedException();
}
}
}
谢谢你的帮助。我已经修复了错误。工作代码如下;我没有用正确的参数调用基构造函数
public class SessionSerializer : MessagePackSerializer<Session>
{
public SessionSerializer(SerializationContext context) : base(context) {
throw new NotImplementedException();
}
protected override void PackToCore(Packer packer, Session objectTree)
{
throw new NotImplementedException();
}
protected override Session UnpackFromCore(Unpacker unpacker)
{
throw new NotImplementedException();
}
}
公共类SessionSerializer:MessagePackSerializer
{
公共会话序列化程序(序列化上下文):基(上下文){
抛出新的NotImplementedException();
}
受保护的覆盖void PackToCore(打包器打包器,会话对象树)
{
抛出新的NotImplementedException();
}
受保护的覆盖会话解包核心(解包解包)
{
抛出新的NotImplementedException();
}
}