Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Fix mapping nullable to nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarypiatek committed Aug 15, 2019
1 parent a89ebff commit ffa7d5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace MappingGenerator.Test.MappingGenerator.TestCaseData
public AddressDTO MainAddress { get; set; }
public ReadOnlyCollection<AddressDTO> Addresses { get; set; }
public int UnitId { get; set; }
public int? Rate { get; set; }
}

public class UserSourceDTO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace MappingGenerator.Test.MappingGenerator.TestCaseData
public AddressDTO MainAddress { get; set; }
public ReadOnlyCollection<AddressDTO> Addresses { get; set; }
public int UnitId { get; set; }
public int? Rate { get; set; }

public UserDTO Clone()
{
Expand Down Expand Up @@ -59,6 +60,7 @@ namespace MappingGenerator.Test.MappingGenerator.TestCaseData
BuildingNo = thisAddress.BuildingNo
}).ToList().AsReadOnly(),
UnitId = UnitId,
Rate = Rate,
Id = Id
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public CloneMappingEngine(SemanticModel semanticModel, SyntaxGenerator syntaxGen

protected override bool ShouldCreateConversionBetweenTypes(ITypeSymbol targetType, ITypeSymbol sourceType)
{
if (targetType.Equals(sourceType) && SymbolHelper.IsNullable(targetType, out _))
{
return false;
}

return ObjectHelper.IsSimpleType(targetType) == false && ObjectHelper.IsSimpleType(sourceType) == false;
}

Expand Down

0 comments on commit ffa7d5c

Please sign in to comment.