Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Fix #48
Browse files Browse the repository at this point in the history
  • Loading branch information
safakgur committed Mar 31, 2020
1 parent 2cfefa0 commit 05b5fa2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Guard.IEnumerable.cs
Expand Up @@ -1047,11 +1047,16 @@ NewExpression GetSetNew(ParameterExpression? comparerParam)

var countGetter = GetCountGetter();
if (countGetter != null)
{
var setCtor = setType.GetConstructor(new[] { typeof(int) });
var countCall = Expression.Call(collectionParam, countGetter);
return Expression.New(setCtor, countCall);
}
try
{
var setCtor = setType.GetConstructor(new[] { typeof(int) });
var countCall = Expression.Call(collectionParam, countGetter);
return Expression.New(setCtor, countCall);
}
catch (Exception)
{
// Swallow and use default
}

return Expression.New(setType);
}
Expand Down

0 comments on commit 05b5fa2

Please sign in to comment.