Custom UserData only deserialized when Description property is constant

I’m developing a C# plugin, and I’ve been struggling to understand why the Read() method is never called on my custom UserData class. I finally discovered the culprit–I had overriden the Description property with something like:

public override string Description
    {
        get { return String.Format("Member: {0}", this.Name); }
    }

I’m assuming the Description is used as a unique identifier for custom UserData types on file open (isn’t this what the GUID attribute is for?), and without a compile-time constant string as the Description it is unable to be found, so Read() is never called. If I change it to something like

public override string Description => "MemberUserData";

then it works fine.

This seems to me like a bug, or a need for better documentation. In any case, I’m describing the issue here in case other developers run into it.

Hi @ScottMitchell,

The underlying openNURBS ON_UserData::GetDescription does not return a constant string.

  /*
  Parameters:
    description - [out] description of user data shown in 
                        object properties dump.
  Returns:
    True if user data class is ready.
  */
  virtual 
  bool GetDescription( ON_wString& description );

I’d need to dig into the .NET wrapper code to give you a better explanation.

– Dale

Thanks for looking at this @dale. I’m not sure exactly what the constraints are, but something about having the Description property reference other properties of the object caused Read() not to be called.