3

我们有声纳报告说我们项目中的许多类违反了MissingSerializationConstructorRule,但是该类及其基类都没有实现任何 Iserializable 接口,有人知道为什么吗?

例如,声纳说:

public class CommentPage : RmdsPublicationPage, ICommentPage 
    { 
 *MissingSerializationConstructorRule    
 The required constructor for ISerializable is not present in this type.* 
    public CommentPage() 
    { 
        this["COMMENTTXT"] = null; 

对应的类在哪里

public class CommentPage : RmdsPublicationPage, ICommentPage
{
    public CommentPage()
    {
        // do something
    }
    public void Update(string comment)
    {
        //something else
    }
}

两个接口也不实现ISerializable,即

public class RmdsPublicationPage : Dictionary<string, object>, IRmdsPublicationPage

public interface IRmdsPublicationPage : IDictionary<string, object>, IDisposable
4

1 回答 1

3

Dictionary(TKey, TValue)实现 ISerializable

[SerializableAttribute]
[ComVisibleAttribute(false)]
public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, 
    ICollection<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, 
    IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, 
    IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, ISerializable, 
    IDeserializationCallback
于 2012-10-23T13:17:00.513 回答