You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My issue with collections and references. When deserialized a collection that includes a reference to an object that was already added I got an exception with the following message: Property type is not defined. Property: "" which is thrown here:
// there is no property type and no expected type defined. Give up!
thrownew InvalidOperationException(string.Format("Property type is not defined. Property: \"{0}\"",
property.Name));
}
The reason for the exception is that property.type is not defined because in the xml string (I guess the same happens also with the binary serializer) there is no type defined for this property, and there shouldn't be one - because it was already defined for the reference object.
So my solution was to move the reference part:
// Is it NullProperty?
var nullProperty = property as NullProperty;
if (nullProperty != null)
{
return null;
}
var referenceTarget = property as ReferenceTargetProperty;
if (referenceTarget!=null && referenceTarget.Reference != null)
{
if (!referenceTarget.Reference.IsProcessed)
{
// object was created already
// get object from cache
return _objectCache[referenceTarget.Reference.Id];
}
}
if (property.Type == null)
{
// there is no property type and no expected type defined. Give up!
throw new InvalidOperationException(string.Format("Property type is not defined. Property: \"{0}\"",
property.Name));
}
// Is it SimpleProperty?
var simpleProperty = property as SimpleProperty;
if (simpleProperty != null)
{
return createObjectFromSimpleProperty(simpleProperty);
}
if (referenceTarget == null)
return null;
object value = createObjectCore(referenceTarget);
if (value != null)
return value;
I don't know how to upload these changes to the code, so I simply outlining this here.
The text was updated successfully, but these errors were encountered:
Hi I've tried using the nuget, but there is some weird behavior with collections. So I downloaded the code, there I found two issues:
The
return true
in line 175 is redundant, causing all properties to be ignored. and results in an empty serialization data.SharpSerializer/SharpSerializer/Advanced/PropertyProvider.cs
Lines 173 to 175 in 0781e02
Removing these lines solved this issue.
My issue with collections and references. When deserialized a collection that includes a reference to an object that was already added I got an exception with the following message:
Property type is not defined. Property: ""
which is thrown here:SharpSerializer/SharpSerializer/Deserializing/ObjectFactory.cs
Lines 82 to 87 in 0781e02
The reason for the exception is that
property.type
is not defined because in the xml string (I guess the same happens also with the binary serializer) there is no type defined for this property, and there shouldn't be one - because it was already defined for the reference object.So my solution was to move the reference part:
SharpSerializer/SharpSerializer/Deserializing/ObjectFactory.cs
Line 96 in 0781e02
and
SharpSerializer/SharpSerializer/Deserializing/ObjectFactory.cs
Lines 100 to 108 in 0781e02
to before line 82 - this solved this issue.
So the new code looks like this:
I don't know how to upload these changes to the code, so I simply outlining this here.
The text was updated successfully, but these errors were encountered: