Skip to content

Commit

Permalink
Merge pull request #2079 from jnyrup/IsTuple
Browse files Browse the repository at this point in the history
Improve performance of `IsTuple()`
  • Loading branch information
jnyrup committed Dec 31, 2022
2 parents 6a03535 + 2e9c03e commit 2ca12e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Src/FluentAssertions/Common/TypeExtensions.cs
Expand Up @@ -547,6 +547,9 @@ private static bool IsTuple(this Type type)
return false;
}

#if !(NET47 || NETSTANDARD2_0)
return typeof(ITuple).IsAssignableFrom(type);
#else
Type openType = type.GetGenericTypeDefinition();
return openType == typeof(ValueTuple<>)
|| openType == typeof(ValueTuple<,>)
Expand All @@ -564,6 +567,7 @@ private static bool IsTuple(this Type type)
|| openType == typeof(Tuple<,,,,,>)
|| openType == typeof(Tuple<,,,,,,>)
|| (openType == typeof(Tuple<,,,,,,,>) && IsTuple(type.GetGenericArguments()[7]));
#endif
}

private static bool IsAnonymousType(this Type type)
Expand Down

0 comments on commit 2ca12e3

Please sign in to comment.