Re: Is.Serializable

"Charlie Poole" <[email protected]> Sun, 7 Sep 2008 10:35:24 -0700
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <000a01c91110$1f6743e0$6401a8c0@ferrari>
This is a multi-part message in MIME format.

--===============1995546840==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_000B_01C910D5.73086BE0"

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C910D5.73086BE0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Fair Enough! I'll put it on both lists.
 
Charlie


  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Simone
Busoli
Sent: Sunday, September 07, 2008 12:24 AM
To: Charlie Poole
Cc: [email protected]
Subject: Re: [Nunit-users] Is.Serializable


Hi Charlie, 

I'd prefer to work on it again, there's been some changes since I wrote it
in the beginning, and it would be useful for me to get comfortable with
them. If you agree, I think this would be the right moment to publish the
list of steps required to create a new constraint.


On Sun, Sep 7, 2008 at 1:33 AM, Charlie Poole <[email protected]>
wrote:


Hi Simone,
 
I'm now back to looking at this patch, which I set aside while working on
other stuff.
 
I agree with you about having two different constraints. Do you want me to
put in
the patch you sent and change the name to "Binary..." or would you like to
rework it?
 
As noted, we do now have a generic AttributeConstraint.
 
Charlie


  _____  


From: Simone Busoli [mailto:[email protected]] 

Sent: Thursday, August 14, 2008 11:15 AM
To: Charlie Poole
Cc: [email protected] 

Subject: Re: [Nunit-users] Is.Serializable




To check just for the attribute or the interface
  Is.Serializable() OR
  Is.Serializable
 
To check by trying to do it
  Is.Serializable(formatter) OR
  Is.Serializable.Using(formatter)


I think that making Is.Serializable check for the presence of the attribute
on the class might be misleading, because its presence doesn't mean it's
serializable, and its absence doesn't mean it isn't. I think that
Is.Serializable should be used to check that an object is really
serializable, together with its references. That is, Is.Serializable should
come in two flavours, one that checks if it is serializable in binary
format, and another for xml. I'll come to this later.
About checking for the presence of the attribute, as you mentioned in a
comment to Fabio's feature request, I think it could be generalized with
Has.Attribute<> or Has.Attribute(Type).
So, given that the presence of an attribute is checked with a generic
Has.Attribute, the way I would tackle the true ability of an object graph to
serialize is either using Is.XmlSerializable and Is.BinarySerializable or
something equivalent. I don't get how you could pass in an instance of a
formatter; I guess you proposed it because you might want to be able to use
the assertion for other types of formatters not built into the .net fx s
well, but then how would you call their methods? Via reflection?
 


 
The aternatives above are between using a method and using a property. It
would be
cool to use the property for te first example and the method for the second,
but 
that's not possible.
 
Most of our syntactic elements use a property format when there is no
argument.
When an element has an optional argument, then we are forced to use method
syntax, which may look a bit odd. For example, we have to use Is.Ordered()
rather than Is.Ordered - That example should be familiar to you :-)
 
I lean toward "Using" or "With" or some other keyword.
 
What do folks think?


I'm fine with anything you choose. I don't think it's so important if it's a
property or a method, just let's try to be consistent :)
 


 

Charlie


  _____  

From: Simone Busoli [mailto:[email protected]] 
Sent: Thursday, August 14, 2008 12:16 AM
To: Charlie Poole
Subject: Re: [Nunit-users] Is.Serializable


Hmm, I just realized that what I'm doing is not enough for the object to be
serializable. I noticed that the prerequisites for it to be serializable are
quite different according to whether you want to serialize it to xml or to
binary. For example, the binary serialization doesn't require classes to be
public, while xml does. xml serialization doesn't require the serializable
attribute, while the binary does. So I'm wondering if it could be the case
to split the assertion in IsBinarySerializable and IsXmlSerializable, or
check that it is both binary and xml serializable in the same assertion.
Thoughts?


On Thu, Aug 14, 2008 at 2:02 AM, Charlie Poole <[email protected]>
wrote:


Hi Simone,
 
This looks good to me. Would you like to synch up and fix it so it works
with the latest code? My major
changes to Constraint, ConstraintBuilder, etc. are done and it would give
you a good way for you
to get familiar with those changes. Once it's done, you can either send me a
new patch or - if
you would like - I'll make you a commiter so you can add it yourself. If you
agree, I'll explain more
to you about review of code etc.
 
Charlie


  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Simone
Busoli
Sent: Monday, August 11, 2008 7:11 AM
To: [email protected]
Subject: [Nunit-users] Is.Serializable


With regards to: http://sourceforge.net/tracker/index.php?func=detail
<http://sourceforge.net/tracker/index.php?func=detail&aid=2028517&group_id=1
0749&atid=360749> &aid=2028517&group_id=10749&atid=360749

I have implemented a SerializableConstraint accessible via Is.Serializable.
The match is true if serialization to and deserialization from a memory
stream via a BinaryFormatter both succeed and the deserialized object is not
null. Otherwise the match returns false.






------=_NextPart_000_000B_01C910D5.73086BE0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.6000.16705" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D203104314-07092008><FONT face=3DArial color=3D#0000ff =
size=3D2>Fair=20
Enough! I'll put it on both lists.</FONT></SPAN></DIV>
<DIV><SPAN class=3D203104314-07092008><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D203104314-07092008><FONT face=3DArial color=3D#0000ff =

size=3D2>Charlie</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
  <HR tabIndex=3D-1>
  <FONT face=3DTahoma size=3D2><B>From:</B>=20
  [email protected]=20
  [mailto:[email protected]] <B>On Behalf Of =
</B>Simone=20
  Busoli<BR><B>Sent:</B> Sunday, September 07, 2008 12:24 =
AM<BR><B>To:</B>=20
  Charlie Poole<BR><B>Cc:</B>=20
  [email protected]<BR><B>Subject:</B> Re: [Nunit-users] =

  Is.Serializable<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV dir=3Dltr>Hi Charlie,
  <DIV><BR></DIV>
  <DIV>I'd prefer to work on it again, there's been some changes since I =
wrote=20
  it in the beginning, and it would be useful for me to get comfortable =
with=20
  them. If you agree, I think this would be the right moment to publish =
the list=20
  of steps required to create a new constraint.<BR><BR>
  <DIV class=3Dgmail_quote>On Sun, Sep 7, 2008 at 1:33 AM, Charlie Poole =
<SPAN=20
  dir=3Dltr>&lt;<A=20
  =
href=3D"mailto:[email protected]">[email protected]</=
A>&gt;</SPAN>=20
  wrote:<BR>
  <BLOCKQUOTE class=3Dgmail_quote=20
  style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: =
#ccc 1px solid">
    <DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>Hi=20
    Simone,</FONT></SPAN></DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>I'm now back =
to looking at=20
    this patch, which I set aside while working on other=20
    stuff.</FONT></SPAN></DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>I agree with =
you about=20
    having two different constraints. Do you want me to put=20
    in</FONT></SPAN></DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>the patch you =
sent and=20
    change the name to "Binary..."&nbsp;or would you like to rework=20
    it?</FONT></SPAN></DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>As noted, we =
do now have a=20
    generic AttributeConstraint.</FONT></SPAN></DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
    size=3D2>Charlie</FONT></SPAN></DIV><BR>
    <BLOCKQUOTE dir=3Dltr=20
    style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff =
2px solid; MARGIN-RIGHT: 0px">
      <DIV lang=3Den-us dir=3Dltr align=3Dleft>
      <HR>
      <FONT face=3DTahoma size=3D2>
      <DIV class=3DIh2E3d><B>From:</B> Simone Busoli [mailto:<A=20
      href=3D"mailto:[email protected]"=20
      target=3D_blank>[email protected]</A>] =
<BR></DIV><B>Sent:</B>=20
      Thursday, August 14, 2008 11:15 AM<BR><B>To:</B> Charlie=20
      Poole<BR><B>Cc:</B> <A =
href=3D"mailto:[email protected]"=20
      target=3D_blank>[email protected]</A>
      <DIV>
      <DIV></DIV>
      <DIV class=3DWj3C7c><BR><B>Subject:</B> Re: [Nunit-users]=20
      Is.Serializable<BR></DIV></DIV></FONT><BR></DIV>
      <DIV>
      <DIV></DIV>
      <DIV class=3DWj3C7c>
      <DIV></DIV>
      <DIV dir=3Dltr>
      <DIV class=3Dgmail_quote>
      <BLOCKQUOTE class=3Dgmail_quote=20
      style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; =
BORDER-LEFT: rgb(204,204,204) 1px solid">
        <DIV><BR>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>To check =
just for the=20
        attribute or the interface</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;=20
        Is.Serializable() OR</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;=20
        Is.Serializable</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2></FONT></SPAN>&nbsp;</DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>To check =
by trying to=20
        do it</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;=20
        Is.Serializable(formatter) OR</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;=20
        =
Is.Serializable.Using(formatter)</FONT></SPAN></DIV></DIV></BLOCKQUOTE>
      <DIV><BR>I think that making Is.Serializable check for the =
presence of the=20
      attribute on the class might be misleading, because its presence =
doesn't=20
      mean it's serializable, and its absence doesn't mean it isn't. I =
think=20
      that Is.Serializable should be used to check that an object is =
really=20
      serializable, together with its references. That is, =
Is.Serializable=20
      should come in two flavours, one that checks if it is serializable =
in=20
      binary format, and another for xml. I'll come to this =
later.<BR>About=20
      checking for the presence of the attribute, as you mentioned in a =
comment=20
      to Fabio's feature request, I think it could be generalized with=20
      Has.Attribute&lt;&gt; or Has.Attribute(Type).<BR>So, given that =
the=20
      presence of an attribute is checked with a generic Has.Attribute, =
the way=20
      I would tackle the true ability of an object graph to serialize is =
either=20
      using Is.XmlSerializable and Is.BinarySerializable or something=20
      equivalent. I don't get how you could pass in an instance of a =
formatter;=20
      I guess you proposed it because you might want to be able to use =
the=20
      assertion for other types of formatters not built into the .net fx =
s well,=20
      but then how would you call their methods? Via =
reflection?<BR>&nbsp;</DIV>
      <BLOCKQUOTE class=3Dgmail_quote=20
      style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; =
BORDER-LEFT: rgb(204,204,204) 1px solid">
        <DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2></FONT></SPAN>&nbsp;</DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>The =
aternatives above=20
        are between using a method and using a property. It would=20
        be</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>cool to =
use the=20
        property for te first example and the method for the second, but =

        </FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>that's =
not=20
        possible.</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2></FONT></SPAN>&nbsp;</DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>Most of =
our syntactic=20
        elements use a property format when there is no=20
        argument.</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>When an =
element has an=20
        optional argument, then we are forced to use =
method</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>syntax, =
which may look=20
        a bit odd. For example, we have to use</FONT></SPAN><SPAN><FONT=20
        face=3DArial color=3D#0000ff size=3D2> =
Is.Ordered()</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>rather =
than Is.Ordered=20
        - That example should be familiar to you :-)</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2></FONT></SPAN>&nbsp;</DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>I lean =
toward "Using"=20
        or "With" or some other keyword.</FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2></FONT></SPAN>&nbsp;</DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>What do =
folks=20
        think?</FONT></SPAN></DIV></DIV></BLOCKQUOTE>
      <DIV><BR>I'm fine with anything you choose. I don't think it's so=20
      important if it's a property or a method, just let's try to be =
consistent=20
      :)<BR>&nbsp;</DIV>
      <BLOCKQUOTE class=3Dgmail_quote=20
      style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; =
BORDER-LEFT: rgb(204,204,204) 1px solid">
        <DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN></DIV>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2></FONT></SPAN>&nbsp;</DIV><FONT color=3D#888888>
        <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
        size=3D2>Charlie</FONT></SPAN></DIV><BR></FONT>
        <BLOCKQUOTE dir=3Dltr=20
        style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: =
rgb(0,0,255) 2px solid; MARGIN-RIGHT: 0px">
          <DIV>
          <DIV lang=3Den-us dir=3Dltr align=3Dleft>
          <HR>
          <FONT face=3DTahoma size=3D2><B>From:</B> Simone Busoli =
[mailto:<A=20
          href=3D"mailto:[email protected]"=20
          target=3D_blank>[email protected]</A>] <BR><B>Sent:</B> =
Thursday,=20
          August 14, 2008 12:16 AM<BR><B>To:</B> Charlie=20
          Poole<BR><B>Subject:</B> Re: [Nunit-users]=20
          Is.Serializable<BR></FONT><BR></DIV>
          <DIV></DIV></DIV>
          <DIV>
          <DIV></DIV>
          <DIV>
          <DIV dir=3Dltr>Hmm, I just realized that what I'm doing is not =
enough=20
          for the object to be serializable. I noticed that the =
prerequisites=20
          for it to be serializable are quite different according to =
whether you=20
          want to serialize it to xml or to binary. For example, the =
binary=20
          serialization doesn't require classes to be public, while xml =
does.=20
          xml serialization doesn't require the serializable attribute, =
while=20
          the binary does. So I'm wondering if it could be the case to =
split the=20
          assertion in IsBinarySerializable and IsXmlSerializable, or =
check that=20
          it is both binary and xml serializable in the same assertion.=20
          Thoughts?<BR><BR>
          <DIV class=3Dgmail_quote>On Thu, Aug 14, 2008 at 2:02 AM, =
Charlie Poole=20
          <SPAN dir=3Dltr>&lt;<A =
href=3D"mailto:[email protected]"=20
          target=3D_blank>[email protected]</A>&gt;</SPAN> =
wrote:<BR>
          <BLOCKQUOTE class=3Dgmail_quote=20
          style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; =
BORDER-LEFT: rgb(204,204,204) 1px solid">
            <DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>Hi=20
            Simone,</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff=20
            size=3D2></FONT></SPAN>&nbsp;</DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>This =
looks good to=20
            me. Would you like to synch up and fix it so it works with =
the=20
            latest code? My major</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff =
size=3D2>changes to=20
            Constraint, ConstraintBuilder, etc. are done and it would =
give you a=20
            good way for you</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>to =
get familiar=20
            with those changes. Once it's done, you can either send me a =
new=20
            patch or - if</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>you =
would like -=20
            I'll make you a commiter so you can add it yourself. If you =
agree,=20
            I'll explain more</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=3DArial color=3D#0000ff size=3D2>to =
you about review=20
            of code etc.</FONT></SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV><SPAN></SPAN><FONT face=3DArial><FONT =
color=3D#0000ff><FONT=20
            size=3D2>C<SPAN>harlie</SPAN></FONT></FONT></FONT><BR></DIV>
            <BLOCKQUOTE dir=3Dltr=20
            style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: =
rgb(0,0,255) 2px solid; MARGIN-RIGHT: 0px">
              <DIV lang=3Den-us dir=3Dltr align=3Dleft>
              <HR>
              <FONT face=3DTahoma size=3D2><B>From:</B> <A=20
              href=3D"mailto:[email protected]"=20
              =
target=3D_blank>[email protected]</A>=20
              [mailto:<A =
href=3D"mailto:[email protected]"=20
              =
target=3D_blank>[email protected]</A>] <B>On=20
              Behalf Of </B>Simone Busoli<BR><B>Sent:</B> Monday, August =
11,=20
              2008 7:11 AM<BR><B>To:</B> <A=20
              href=3D"mailto:[email protected]"=20
              =
target=3D_blank>[email protected]</A><BR><B>Subject:</B> =

              [Nunit-users] Is.Serializable<BR></FONT><BR></DIV>
              <DIV>
              <DIV></DIV>
              <DIV dir=3Dltr>With regards to: <A=20
              =
href=3D"http://sourceforge.net/tracker/index.php?func=3Ddetail&amp;aid=3D=
2028517&amp;group_id=3D10749&amp;atid=3D360749"=20
              =
target=3D_blank>http://sourceforge.net/tracker/index.php?func=3Ddetail&am=
p;aid=3D2028517&amp;group_id=3D10749&amp;atid=3D360749</A><BR><BR>I=20
              have implemented a SerializableConstraint accessible via=20
              Is.Serializable. The match is true if serialization to and =

              deserialization from a memory stream via a BinaryFormatter =
both=20
              succeed and the deserialized object is not null. Otherwise =
the=20
              match returns=20
          =
false.<BR></DIV></DIV></BLOCKQUOTE></DIV></BLOCKQUOTE></DIV><BR></DIV></D=
IV></DIV></BLOCKQUOTE></DIV></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV></BL=
OCKQUOTE></DIV></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></BODY></H=
TML>

------=_NextPart_000_000B_01C910D5.73086BE0--




--===============1995546840==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--===============1995546840==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users

--===============1995546840==--