diff --git a/src/AoCHelper/Solver.cs b/src/AoCHelper/Solver.cs
index a35ea36..626b07e 100644
--- a/src/AoCHelper/Solver.cs
+++ b/src/AoCHelper/Solver.cs
@@ -1,6 +1,6 @@
-using Spectre.Console;
-using System.Diagnostics;
+using System.Diagnostics;
using System.Reflection;
+using Spectre.Console;
namespace AoCHelper
{
@@ -32,7 +32,7 @@ await AnsiConsole.Live(table)
.Cropping(configuration.VerticalOverflowCropping)
.StartAsync(async ctx =>
{
- var lastProblem = LoadAllProblems(Assembly.GetEntryAssembly()!).LastOrDefault();
+ var lastProblem = LoadAllProblems(configuration.ProblemAssemblies).LastOrDefault();
if (lastProblem is not null)
{
var sw = new Stopwatch();
@@ -137,7 +137,7 @@ await AnsiConsole.Live(table)
.StartAsync(async ctx =>
{
var sw = new Stopwatch();
- foreach (Type problemType in LoadAllProblems(Assembly.GetEntryAssembly()!))
+ foreach (Type problemType in LoadAllProblems(configuration.ProblemAssemblies))
{
if (problems.Contains(problemType))
{
@@ -187,7 +187,7 @@ await AnsiConsole.Live(table)
.StartAsync(async ctx =>
{
var sw = new Stopwatch();
- foreach (Type problemType in LoadAllProblems(Assembly.GetEntryAssembly()!))
+ foreach (Type problemType in LoadAllProblems(configuration.ProblemAssemblies))
{
sw.Restart();
// Since we're trying to instantiate them all, we don't want to show unrelated errors or render unrelated problem rows
@@ -231,7 +231,7 @@ await AnsiConsole.Live(table)
.StartAsync(async ctx =>
{
var sw = new Stopwatch();
- foreach (Type problemType in LoadAllProblems(Assembly.GetEntryAssembly()!))
+ foreach (Type problemType in LoadAllProblems(configuration.ProblemAssemblies))
{
sw.Restart();
var potentialProblem = InstantiateProblem(problemType);
@@ -253,13 +253,13 @@ await AnsiConsole.Live(table)
}
///
- /// Loads all in the given assembly
+ /// Loads all in the given assemblies
///
- ///
+ ///
///
- internal static IEnumerable LoadAllProblems(Assembly assembly)
+ internal static IEnumerable LoadAllProblems(List assemblies)
{
- return assembly.GetTypes()
+ return assemblies.SelectMany(a => a.GetTypes())
.Where(type => typeof(BaseProblem).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
.OrderBy(t => t.FullName);
}
diff --git a/src/AoCHelper/SolverConfiguration.cs b/src/AoCHelper/SolverConfiguration.cs
index 9d084fe..fbeb83a 100644
--- a/src/AoCHelper/SolverConfiguration.cs
+++ b/src/AoCHelper/SolverConfiguration.cs
@@ -1,4 +1,5 @@
-using Spectre.Console;
+using System.Reflection;
+using Spectre.Console;
namespace AoCHelper
{
@@ -33,6 +34,12 @@ public class SolverConfiguration
///
public string? ElapsedTimeFormatSpecifier { get; set; }
+ ///
+ /// Assemblies where the problems are located.
+ /// Defaults to the entry assembly: [Assembly.GetEntryAssembly()!]
+ ///
+ public List ProblemAssemblies { get; set; }
+
///
/// Represents vertical overflow.
///
@@ -47,6 +54,8 @@ public class SolverConfiguration
public SolverConfiguration()
{
+ ProblemAssemblies = [Assembly.GetEntryAssembly()!];
+
ClearConsole = true;
ShowOverallResults = true;
ShowConstructorElapsedTime = false;
diff --git a/tests/AoCHelper.Test/SolverTest.cs b/tests/AoCHelper.Test/SolverTest.cs
index 66c1c05..ec7562f 100644
--- a/tests/AoCHelper.Test/SolverTest.cs
+++ b/tests/AoCHelper.Test/SolverTest.cs
@@ -117,14 +117,14 @@ public void LoadAllProblems()
{
Assert.Equal(
Assembly.GetExecutingAssembly()!.GetTypes().Count(type => typeof(BaseProblem).IsAssignableFrom(type) && !type.IsAbstract),
- Solver.LoadAllProblems(Assembly.GetExecutingAssembly()).Count());
+ Solver.LoadAllProblems([Assembly.GetExecutingAssembly()]).Count());
}
[Fact]
public void LoadAllProblems_OrderedByFullName()
{
- var orderedTypes = Solver.LoadAllProblems(Assembly.GetExecutingAssembly()).OrderBy(t => t.FullName);
- var types = Solver.LoadAllProblems(Assembly.GetExecutingAssembly());
+ var orderedTypes = Solver.LoadAllProblems([Assembly.GetExecutingAssembly()]).OrderBy(t => t.FullName);
+ var types = Solver.LoadAllProblems([Assembly.GetExecutingAssembly()]);
foreach (var (First, Second) in orderedTypes.Zip(types))
{