[Mono-bugs] [Bug 553063] New: System.Web.HttpCookie+CookieNVC is not marked as Serializable

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 5 17:31:20 EST 2009


           Summary: System.Web.HttpCookie+CookieNVC is not marked as
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Web
        AssignedTo: mhabersack at novell.com
        ReportedBy: sean.foy+novell at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=325864)
 --> (http://bugzilla.novell.com/attachment.cgi?id=325864)
HttpCookie+CookieNVC should have [SerializableAttribute]

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US;
rv: Gecko/20091016 Firefox/3.5.4

HttpCookie.Values has static type
System.Collections.Specialized.NameValueCollection, which is decorated with
SerializableAttribute. On .NET, the following code works:
var bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
using (var ms = new System.IO.MemoryStream()) {
    bf.Serialize(ms, cookieValues);
    ms.Seek(0, SeekOrigin.Begin);
    // work with ms

On Mono -r144494, that code yields
System.Runtime.Serialization.SerializationException : Type
System.Web.HttpCookie+CookieNVC is not marked as Serializable.

Generally, the Liskov substitution principle implies that subclasses of
Serializable classes should themselves be Serializable. I guess
SerializableAttribute is defined as nonheritable for a reason. In this case,
though, the only reason we've subclassed NameValueCollection is to specialize
ToString (says the doc comment).

So, I propose the attached patch.

Reproducible: Always

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list