-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-5632: Consolidate driver project Type extension methods in Misc\TypeExtensions.cs #1815
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
base: main
Are you sure you want to change the base?
Conversation
sanych-sun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are here, could we also remove the unnecessary else blocks in some of the methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I noticed that the methods: TryGetIEnumerableGenericInterface; TryGetIListGenericInterface; TryGetIQueryableGenericInterface all have nearly identical implementations. Could they be consolidated to use the existing TryGetGenericInterface helper?
something like:
public static bool TryGetIEnumerableGenericInterface(this Type type, out Type ienumerableGenericInterface)
{
return TryGetGenericInterface(type, new[] { typeof(IEnumerable<>) }, out ienumerableGenericInterface);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done except slightly differently. I added an overload of TryGetGenerricInterface that only takes a single generic interface definition to match against. Should be slightly more efficient than the array version when there is only one definition involved.
sanych-sun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
adelinowona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.