Skip to content

Commit

Permalink
Fixed NullReferenceException in ReflectionUtils.IsRecordType, fixed b…
Browse files Browse the repository at this point in the history
…ack mapping IEnumerable classes.
  • Loading branch information
satano committed Sep 28, 2017
1 parent 1649ab9 commit 8d6bb0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/Mapster.Tests/WhenMappingIEnumerableClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class ClassA

public class ClassB : IEnumerable
{

public int Id { get; set; }

public IEnumerator GetEnumerator()
Expand All @@ -24,7 +23,7 @@ public IEnumerator GetEnumerator()
}
}

[TestMethod, Ignore]
[TestMethod]
public void Map_To_IEnumerable_Class_Should_Pass()
{
ClassA classA = new ClassA()
Expand Down
10 changes: 1 addition & 9 deletions src/Mapster/Utils/ReflectionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public static bool IsNullable(this Type type)

public static bool IsPoco(this Type type, BindingFlags accessorFlags = BindingFlags.Public)
{
//not collection
if (type.IsCollection())
return false;

//not nullable
if (type.IsNullable())
return false;
Expand Down Expand Up @@ -169,10 +165,6 @@ public static bool IsReferenceAssignableFrom(this Type destType, Type srcType)

public static bool IsRecordType(this Type type)
{
//not collection
if (type.IsCollection())
return false;

//not nullable
if (type.IsNullable())
return false;
Expand All @@ -195,7 +187,7 @@ public static bool IsRecordType(this Type type)
return props.All(prop =>
{
var name = prop.Name.ToPascalCase();
return ctors[0].GetParameters().Any(p => p.ParameterType == prop.Type && p.Name.ToPascalCase() == name);
return ctors[0].GetParameters().Any(p => p.ParameterType == prop.Type && p.Name?.ToPascalCase() == name);
});
}

Expand Down

0 comments on commit 8d6bb0c

Please sign in to comment.