Skip to content

Commit

Permalink
Swap use of deprecated FindAll method to Where/ToArray
Browse files Browse the repository at this point in the history
castleproject#612 - Updating Windsor to support Castle.Core@5.0.0 and modern TFMs
  • Loading branch information
Jevonius committed May 14, 2022
1 parent 73bcc00 commit dd4a0c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Castle.Windsor/Core/Internal/ReflectionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static Type[] GetAvailableTypes(this Assembly assembly, bool includeNonEx
}
catch (ReflectionTypeLoadException e)
{
return e.Types.FindAll(t => t != null);
return e.Types.Where(t => t != null).ToArray();
// NOTE: perhaps we should not ignore the exceptions here, and log them?
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

namespace Castle.Windsor.Diagnostics
{
using Castle.Core.Internal;
using System.Linq;

using Castle.MicroKernel;

public class PotentiallyMisconfiguredComponentsDiagnostic : IPotentiallyMisconfiguredComponentsDiagnostic
Expand All @@ -29,7 +30,7 @@ public PotentiallyMisconfiguredComponentsDiagnostic(IKernel kernel)
public IHandler[] Inspect()
{
var allHandlers = kernel.GetAssignableHandlers(typeof(object));
var waitingHandlers = allHandlers.FindAll(IsWaitingForDependencies);
var waitingHandlers = allHandlers.Where(IsWaitingForDependencies).ToArray();
return waitingHandlers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ public UsingContainerAsServiceLocatorDiagnostic(IKernel kernel)
public IHandler[] Inspect()
{
var allHandlers = kernel.GetAssignableHandlers(typeof(object));
var handlersWithContainerDependency = allHandlers.FindAll(HasDependencyOnTheContainer);
return handlersWithContainerDependency.FindAll(h => ExceptionsToTheRule.Any(e => e(h)) == false);
var handlersWithContainerDependency = allHandlers.Where(HasDependencyOnTheContainer);
return handlersWithContainerDependency
.Where(h => ExceptionsToTheRule.Any(e => e(h)) == false)
.ToArray();
}

private bool HasDependencyOnTheContainer(IHandler handler)
Expand Down

0 comments on commit dd4a0c9

Please sign in to comment.