Re: Is.Serializable

"Simone Busoli" <[email protected]> Sun, 7 Sep 2008 09:23:44 +0200
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
--===============1333766821==
Content-Type: multipart/alternative; 
	boundary="----=_Part_64456_13727414.1220772224336"

------=_Part_64456_13727414.1220772224336
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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 useIs.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&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.
>>>
>>>
>>
>

------=_Part_64456_13727414.1220772224336
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr">Hi Charlie,<div><br></div><div>I&#39;d prefer to work on it again, there&#39;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.<br>
<br><div class="gmail_quote">On Sun, Sep 7, 2008 at 1:33 AM, Charlie Poole <span dir="ltr">&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">




<div>
<div><span><font face="Arial" color="#0000ff" size="2">Hi 
Simone,</font></span></div>
<div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div><span><font face="Arial" color="#0000ff" size="2">I&#39;m 
now back to looking at this patch, which I set aside while working on other 
stuff.</font></span></div>
<div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div><span><font face="Arial" color="#0000ff" size="2">I 
agree with you about having two different constraints. Do you want me to put 
in</font></span></div>
<div><span><font face="Arial" color="#0000ff" size="2">the 
patch you sent and change the name to &quot;Binary...&quot;&nbsp;or would you like to 
rework it?</font></span></div>
<div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div><span><font face="Arial" color="#0000ff" size="2">As 
noted, we do now have a generic AttributeConstraint.</font></span></div>
<div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div><span><font face="Arial" color="#0000ff" size="2">Charlie</font></span></div><br>
<blockquote dir="ltr" style="padding-left:5px;margin-left:5px;border-left:#0000ff 2px solid;margin-right:0px">
  <div lang="en-us" dir="ltr" align="left">
  <hr>
  <font face="Tahoma" size="2"><div class="Ih2E3d"><b>From:</b> Simone Busoli 
  [mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>] <br></div><b>Sent:</b> Thursday, August 14, 2008 
  11:15 AM<br><b>To:</b> Charlie Poole<br><b>Cc:</b> 
  <a href="mailto:[email protected]" target="_blank">[email protected]</a><div><div></div><div class="Wj3C7c"><br><b>Subject:</b> Re: [Nunit-users] 
  Is.Serializable<br></div></div></font><br></div><div><div></div><div class="Wj3C7c">
  <div></div>
  <div dir="ltr">
  <div class="gmail_quote">
  <blockquote class="gmail_quote" style="padding-left:1ex;margin:0pt 0pt 0pt 0.8ex;border-left:rgb(204,204,204) 1px solid">
    <div><br>
    <div><span><font face="Arial" color="#0000ff" size="2">To check just for the 
    attribute or the interface</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">&nbsp; Is.Serializable() 
    OR</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">&nbsp; 
    Is.Serializable</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
    <div><span><font face="Arial" color="#0000ff" size="2">To check by trying to do 
    it</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">&nbsp; 
    Is.Serializable(formatter) OR</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">&nbsp; 
    Is.Serializable.Using(formatter)</font></span></div></div></blockquote>
  <div><br>I think that making Is.Serializable check for the presence of the 
  attribute on the class might be misleading, because its presence doesn&#39;t mean 
  it&#39;s serializable, and its absence doesn&#39;t mean it isn&#39;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&#39;ll come to this later.<br>About checking for the presence of the 
  attribute, as you mentioned in a comment to Fabio&#39;s feature request, I think 
  it could be generalized with Has.Attribute&lt;&gt; or 
  Has.Attribute(Type).<br>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&#39;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?<br>&nbsp;</div>
  <blockquote class="gmail_quote" style="padding-left:1ex;margin:0pt 0pt 0pt 0.8ex;border-left:rgb(204,204,204) 1px solid">
    <div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
    <div><span><font face="Arial" color="#0000ff" size="2">The aternatives above are 
    between using a method and using a property. It would be</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">cool to use the property 
    for te first example and the method for the second, but </font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">that&#39;s not 
    possible.</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
    <div><span><font face="Arial" color="#0000ff" size="2">Most of our syntactic 
    elements use a property format when there is no 
argument.</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">When an element has an 
    optional argument, then we are forced to use method</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">syntax, which may look a 
    bit odd. For example, we have to use</font></span><span><font face="Arial" color="#0000ff" size="2"> Is.Ordered()</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2">rather than Is.Ordered - 
    That example should be familiar to you :-)</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
    <div><span><font face="Arial" color="#0000ff" size="2">I lean toward &quot;Using&quot; or 
    &quot;With&quot; or some other keyword.</font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
    <div><span><font face="Arial" color="#0000ff" size="2">What do folks 
    think?</font></span></div></div></blockquote>
  <div><br>I&#39;m fine with anything you choose. I don&#39;t think it&#39;s so important if 
  it&#39;s a property or a method, just let&#39;s try to be consistent 
:)<br>&nbsp;</div>
  <blockquote class="gmail_quote" style="padding-left:1ex;margin:0pt 0pt 0pt 0.8ex;border-left:rgb(204,204,204) 1px solid">
    <div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span></div>
    <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div><font color="#888888">
    <div><span><font face="Arial" color="#0000ff" size="2">Charlie</font></span></div><br></font>
    <blockquote dir="ltr" style="padding-left:5px;margin-left:5px;border-left:rgb(0,0,255) 2px solid;margin-right:0px">
      <div>
      <div lang="en-us" dir="ltr" align="left">
      <hr>
      <font face="Tahoma" size="2"><b>From:</b> Simone Busoli [mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>] <br><b>Sent:</b> Thursday, 
      August 14, 2008 12:16 AM<br><b>To:</b> Charlie Poole<br><b>Subject:</b> 
      Re: [Nunit-users] Is.Serializable<br></font><br></div>
      <div></div></div>
      <div>
      <div></div>
      <div>
      <div dir="ltr">Hmm, I just realized that what I&#39;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&#39;t require classes to be public, while xml does. xml serialization 
      doesn&#39;t require the serializable attribute, while the binary does. So I&#39;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?<br><br>
      <div class="gmail_quote">On Thu, Aug 14, 2008 at 2:02 AM, Charlie Poole 
      <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
      <blockquote class="gmail_quote" style="padding-left:1ex;margin:0pt 0pt 0pt 0.8ex;border-left:rgb(204,204,204) 1px solid">
        <div>
        <div><span><font face="Arial" color="#0000ff" size="2">Hi 
        Simone,</font></span></div>
        <div><span><font face="Arial" color="#0000ff" size="2"></font></span>&nbsp;</div>
        <div><span><font face="Arial" color="#0000ff" size="2">This looks good to me. 
        Would you like to synch up and fix it so it works with the latest code? 
        My major</font></span></div>
        <div><span><font face="Arial" color="#0000ff" size="2">changes to Constraint, 
        ConstraintBuilder, etc. are done and it would give you a good way for 
        you</font></span></div>
        <div><span><font face="Arial" color="#0000ff" size="2">to get familiar with 
        those changes. Once it&#39;s done, you can either send me a new patch or - 
        if</font></span></div>
        <div><span><font face="Arial" color="#0000ff" size="2">you would like - I&#39;ll 
        make you a commiter so you can add it yourself. If you agree, I&#39;ll 
        explain more</font></span></div>
        <div><span><font face="Arial" color="#0000ff" size="2">to you about review of 
        code etc.</font></span></div>
        <div>&nbsp;</div>
        <div><span></span><font face="Arial"><font color="#0000ff"><font size="2">C<span>harlie</span></font></font></font><br></div>
        <blockquote dir="ltr" style="padding-left:5px;margin-left:5px;border-left:rgb(0,0,255) 2px solid;margin-right:0px">
          <div lang="en-us" dir="ltr" align="left">
          <hr>
          <font face="Tahoma" size="2"><b>From:</b> <a href="mailto:[email protected]" target="_blank">[email protected]</a> [mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>] <b>On 
          Behalf Of </b>Simone Busoli<br><b>Sent:</b> Monday, August 11, 2008 
          7:11 AM<br><b>To:</b> <a href="mailto:[email protected]" target="_blank">[email protected]</a><br><b>Subject:</b> 
          [Nunit-users] Is.Serializable<br></font><br></div>
          <div>
          <div></div>
          <div dir="ltr">With regards to: <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=2028517&amp;group_id=10749&amp;atid=360749" target="_blank">http://sourceforge.net/tracker/index.php?func=detail&amp;aid=2028517&amp;group_id=10749&amp;atid=360749</a><br>
<br>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.<br></div></div></blockquote></div></blockquote></div><br></div></div></div></blockquote></div></blockquote></div><br></div></div></div></blockquote></div>
</blockquote></div><br></div></div>

------=_Part_64456_13727414.1220772224336--


--===============1333766821==
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=/
--===============1333766821==
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

--===============1333766821==--