RusticiSoftware / TinCanAPILibraryCSharp

DEPRECATION NOTICE: This library is deprecated, use the TinCan.NET library instead
http://rusticisoftware.github.io/TinCan.NET/
14 stars 12 forks source link

Error deserializing Actor #14

Open pallu opened 10 years ago

pallu commented 10 years ago

Actor.cs has this as code

public string Mbox_sha1sum
    {
        get { return mbox_sha1sum; }
        set
        {
            mbox_sha1sum = value.ToLower();
        }
    }

    /// <summary>
    /// Array of OpenIDs for the actor
    /// </summary>
    public string Openid
    {
        get { return openid; }
        set
        {
            openid = value.ToLower();
        }
    }

I am saving my statements to MongoDb. When I try to get back Actors, there is a deserialization error because the mbox_sha1sum and OpenID are nulls and hence, the ToLower() throws an error. I had to modify the two setters as follows:

public string Mbox_sha1sum
    {
        get { return mbox_sha1sum; }
        set
        {
            mbox_sha1sum = (value == null)?null : value.ToLower();
        }
    }

    /// <summary>
    /// Array of OpenIDs for the actor
    /// </summary>
    public string Openid
    {
        get { return openid; }
        set
        {
            openid = (value == null) ? null : value.ToLower();
        }
    }
brianjmiller commented 10 years ago

I'm a little curious why it is using .ToLower() in the first place. There isn't any reason to adjust the value at all. AFAICT a SHA1 will always use lower, but that still isn't a reason to adjust for poor data, if the user has an invalid SHA1 then they should be told that rather than cover it up. I didn't bother checking for an OpenID but this lib still shouldn't try to correct for formats.

pallu commented 10 years ago

Agreed, can't say why the .ToLower() is there in the first place.