Skip to content

Commit

Permalink
Merge pull request #4656 from RenderMichael/arrays
Browse files Browse the repository at this point in the history
Use obj is Array instead of obj.GetType().IsArray
  • Loading branch information
manfred-brands committed Mar 9, 2024
2 parents ac561dd + d90877c commit f4f266b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ internal static class ArraysComparer
{
public static EqualMethodResult Equal(object x, object y, ref Tolerance tolerance, ComparisonState state, NUnitEqualityComparer equalityComparer)
{
if (!x.GetType().IsArray || !y.GetType().IsArray || equalityComparer.CompareAsCollection)
if (x is not Array xArray || y is not Array yArray || equalityComparer.CompareAsCollection)
return EqualMethodResult.TypesNotSupported;

Array xArray = (Array)x;
Array yArray = (Array)y;

int rank = xArray.Rank;

if (rank != yArray.Rank)
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitFramework/framework/Constraints/MsgUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static MsgUtils()

AddFormatter(next => val => val is DictionaryEntry de ? FormatKeyValuePair(de.Key, de.Value) : next(val));

AddFormatter(next => val => val.GetType().IsArray ? FormatArray((Array)val) : next(val));
AddFormatter(next => val => val is Array valArray ? FormatArray(valArray) : next(val));

AddFormatter(next => val => TryFormatKeyValuePair(val) ?? next(val));

Expand Down

0 comments on commit f4f266b

Please sign in to comment.