Mono与.NET的评估差异的可能顺序

时间:2013-03-07 23:17:40

标签: mono protobuf-net

我在一个对象上有一个Equals覆盖,用于检查使用预编译的protobuf-net serialiser对象反序列化的两个对象之间的值相等性。我已经验证了反序列化按预期发生(在那个注释中,protobuf-net非常棒)。

这个类很简单,但是其他更复杂的问题也会出现同样的问题,所以我会用它作为模型。

以下是相关代码片段:

public bool Equals (CompressionConfiguration other) {
    if (ReferenceEquals(null, other)) return false;
    if (ReferenceEquals(this, other)) return true;
return string.Equals (AlgorithmName, other.AlgorithmName) &&
        (AlgorithmConfiguration == null ? other.AlgorithmConfiguration == null : 
        AlgorithmConfiguration.SequenceEqual(other.AlgorithmConfiguration));
}

在.NET运行时下执行时,会按预期进行求值,允许AlgorithmConfiguration为null,其为byte []类型。在Mono下,我得到一个SequenceEqual null参数错误,特别是ArgumentNullException。是什么赋予了?这不应该发生,因为只有在AlgorithmConfiguration!= null。

时才应该调用SequenceEqual

这绝对是源,因为如果我为CompressionConfiguration提供零长度字节[],则不会发生故障。如果可能的话,我真的不想发送零长度数组。 我必须具有Mono兼容性,因为它将用于Xamarin.Android(MonoDroid)和MonoTouch,以及Mono服务器和.NET桌面应用程序。

1 个答案:

答案 0 :(得分:0)

奇怪的是,在Mono下重新编译序列化程序集解决了这个问题,即使这不是ArgumentNullException的起源,我已经验证了对象已经正确反序列化了。现在一切都有效。