Skip to content

Commit

Permalink
Don't set EditorAlias if it's not blank #64
Browse files Browse the repository at this point in the history
Not setting the editor alias unless we have to, and making sure it matches the datatype we actually found.
  • Loading branch information
Kevin Jump committed Nov 4, 2019
1 parent 0ee3f4d commit abb9af3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions uSync8.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,24 +516,25 @@ private PropertyType GetOrCreateProperty(TObject item,
property = item.PropertyTypes.SingleOrDefault(x => x.Alias == alias);
}

var editorAlias = propertyEditorAlias;

IDataType dataType = default(IDataType);
if (definitionKey != Guid.Empty)
{
dataType = dataTypeService.GetDataType(definitionKey);
}

if (dataType == null)
if (dataType == null && !string.IsNullOrEmpty(propertyEditorAlias))
{
// look the datatype up by alias ?
if (!string.IsNullOrEmpty(propertyEditorAlias))
{
dataType = dataTypeService.GetDataType(propertyEditorAlias);
}

dataType = dataTypeService.GetDataType(propertyEditorAlias);
}

if (dataType == null) return null;

// we set it here, this means if the file is in conflict (because its changed in the datatype),
// we shouldn't reset it later on should we set the editor alias value.
editorAlias = dataType.EditorAlias;

// if it's null then it doesn't exist (so it's new)
if (property == null)
{
Expand All @@ -551,7 +552,8 @@ private PropertyType GetOrCreateProperty(TObject item,


// thing that could break if they where blank.
if (!string.IsNullOrWhiteSpace(propertyEditorAlias))
// update, only set this if its not already set (because we don't want to break things!)
if (string.IsNullOrWhiteSpace(property.PropertyEditorAlias) && !string.IsNullOrWhiteSpace(propertyEditorAlias))
property.PropertyEditorAlias = propertyEditorAlias;

if (property.DataTypeId != dataType.Id)
Expand Down

0 comments on commit abb9af3

Please sign in to comment.