Skip to content

Commit

Permalink
Clarify compatibility with arrays in GetCollectionItemType()
Browse files Browse the repository at this point in the history
  • Loading branch information
skrysmanski committed May 6, 2024
1 parent 364cb41 commit 110d146
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AppMotor.Core/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ public static bool IsNullableValueType(this Type type)
/// Returns the item type if this type is a collection (i.e. inheriting from <see cref="IEnumerable{T}"/>).
/// Returns <c>null</c> if this type is not a collection type or not a generic collection type.
/// </summary>
/// <remarks>
/// This method also works if this type is an array type.
/// </remarks>
/// <exception cref="AmbiguousMatchException">Thrown if this type implements <see cref="IEnumerable{T}"/> multiple
/// times with different type arguments.</exception>
[MustUseReturnValue]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public void Test_GetCollectionItemType()
{
typeof(List<string>).GetCollectionItemType().ShouldBe(typeof(string));
typeof(IReadOnlyCollection<int>).GetCollectionItemType().ShouldBe(typeof(int));
typeof(bool[]).GetCollectionItemType().ShouldBe(typeof(bool));

typeof(StringComparer).GetCollectionItemType().ShouldBe(null);

Expand Down

0 comments on commit 110d146

Please sign in to comment.