Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of IsTuple() #2079

Merged
merged 1 commit into from Dec 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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