Skip to content

Commit

Permalink
Revert "Fixed NullReferenceException in ReflectionUtils.IsRecordType,…
Browse files Browse the repository at this point in the history
… when there was parameters without name."

This reverts commit bd72105.
  • Loading branch information
satano committed Sep 28, 2017
1 parent bd72105 commit 1649ab9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Mapster.Tests/WhenMappingIEnumerableClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ClassA

public class ClassB : IEnumerable
{

public int Id { get; set; }

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

[TestMethod]
[TestMethod, Ignore]
public void Map_To_IEnumerable_Class_Should_Pass()
{
ClassA classA = new ClassA()
Expand Down
10 changes: 9 additions & 1 deletion src/Mapster/Utils/ReflectionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ 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 @@ -165,6 +169,10 @@ 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 @@ -187,7 +195,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 1649ab9

Please sign in to comment.