diff --git a/src/AoCHelper/Solver.cs b/src/AoCHelper/Solver.cs index 129ac89..a35ea36 100644 --- a/src/AoCHelper/Solver.cs +++ b/src/AoCHelper/Solver.cs @@ -252,264 +252,6 @@ await AnsiConsole.Live(table) RenderOverallResultsPanel(totalElapsedTime, configuration); } - #region Obsolete - - /// - /// Use instead - /// - /// - /// await Solver.SolveLast(opt => opt.ShowConstructorElapsedTime = true); - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task SolveLast(SolverConfiguration? configuration) - { - configuration ??= new(); - if (IsInteractiveEnvironment && configuration.ClearConsole) - { - AnsiConsole.Clear(); - } - - var table = GetTable(); - - await AnsiConsole.Live(table) - .AutoClear(false) - .Overflow(configuration.VerticalOverflow) - .Cropping(configuration.VerticalOverflowCropping) - .StartAsync(async ctx => - { - var lastProblem = LoadAllProblems(Assembly.GetEntryAssembly()!).LastOrDefault(); - if (lastProblem is not null) - { - var sw = new Stopwatch(); - sw.Start(); - var potentialProblem = Activator.CreateInstance(lastProblem); - sw.Stop(); - - if (potentialProblem is BaseProblem problem) - { - await SolveProblem(problem, table, CalculateElapsedMilliseconds(sw), configuration); - ctx.Refresh(); - } - } - }); - } - - /// - /// Use instead - /// - /// - /// await Solver.Solve{Day01}(opt => opt.ShowConstructorElapsedTime = true); - /// - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task Solve(SolverConfiguration? configuration) - where TProblem : BaseProblem, new() - { - configuration ??= new(); - if (IsInteractiveEnvironment && configuration.ClearConsole) - { - AnsiConsole.Clear(); - } - - var table = GetTable(); - - await AnsiConsole.Live(table) - .AutoClear(false) - .Overflow(configuration.VerticalOverflow) - .Cropping(configuration.VerticalOverflowCropping) - .StartAsync(async ctx => - { - var sw = new Stopwatch(); - sw.Start(); - TProblem problem = new(); - sw.Stop(); - - await SolveProblem(problem, table, CalculateElapsedMilliseconds(sw), configuration); - ctx.Refresh(); - }); - } - - /// - /// Use instead - /// - /// - /// await Solver.Solve(opt => opt.ShowConstructorElapsedTime = true, 1, 2); - /// - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task Solve(SolverConfiguration? configuration, params uint[] problemNumbers) - => await Solve(problemNumbers.AsEnumerable(), configuration); - - /// - /// Use instead - /// - /// - /// await Solver.Solve(opt => opt.ShowConstructorElapsedTime = true, typeof(Problem66)); - /// - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task Solve(SolverConfiguration? configuration, params Type[] problems) - => await Solve(problems.AsEnumerable(), configuration); - - /// - /// Use instead - /// - /// - /// await Solver.Solve(new uint[] { 1 }, opt => opt.ShowConstructorElapsedTime = true); - /// - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task Solve(IEnumerable problemNumbers, SolverConfiguration? configuration) - { - configuration ??= new(); - if (IsInteractiveEnvironment && configuration.ClearConsole) - { - AnsiConsole.Clear(); - } - - var totalElapsedTime = new List(); - var table = GetTable(); - - await AnsiConsole.Live(table) - .AutoClear(false) - .Overflow(configuration.VerticalOverflow) - .Cropping(configuration.VerticalOverflowCropping) - .StartAsync(async ctx => - { - var sw = new Stopwatch(); - foreach (Type problemType in LoadAllProblems(Assembly.GetEntryAssembly()!)) - { - sw.Restart(); - var potentialProblem = Activator.CreateInstance(problemType); - sw.Stop(); - - if (potentialProblem is BaseProblem problem && problemNumbers.Contains(problem.CalculateIndex())) - { - totalElapsedTime.Add(await SolveProblem(problem, table, CalculateElapsedMilliseconds(sw), configuration)); - ctx.Refresh(); - } - } - }); - - RenderOverallResultsPanel(totalElapsedTime, configuration); - } - - /// - /// Use instead - /// - /// - /// await Solver.Solve(new [] { typeof(Day10) }, opt => opt.ShowConstructorElapsedTime = true); - /// - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task Solve(IEnumerable problems, SolverConfiguration? configuration) - { - configuration ??= new(); - if (IsInteractiveEnvironment && configuration.ClearConsole) - { - AnsiConsole.Clear(); - } - - var totalElapsedTime = new List(); - var table = GetTable(); - - await AnsiConsole.Live(table) - .AutoClear(false) - .Overflow(configuration.VerticalOverflow) - .Cropping(configuration.VerticalOverflowCropping) - .StartAsync(async ctx => - { - var sw = new Stopwatch(); - foreach (Type problemType in LoadAllProblems(Assembly.GetEntryAssembly()!)) - { - if (problems.Contains(problemType)) - { - sw.Restart(); - var potentialProblem = Activator.CreateInstance(problemType); - sw.Stop(); - - if (potentialProblem is BaseProblem problem) - { - totalElapsedTime.Add(await SolveProblem(problem, table, CalculateElapsedMilliseconds(sw), configuration)); - ctx.Refresh(); - } - } - } - }); - - RenderOverallResultsPanel(totalElapsedTime, configuration); - } - - /// - /// Use instead - /// - /// - /// await Solver.SolveAll(options => - /// { - /// options.ShowConstructorElapsedTime = true; - /// options.ShowOverallResults = true; - /// options.ClearConsole = false; - /// }); - /// - /// - /// - /// - [Obsolete("Use Action? overload instead")] - public static async Task SolveAll(SolverConfiguration? configuration) - { - configuration ??= new(); - if (IsInteractiveEnvironment && configuration.ClearConsole) - { - AnsiConsole.Clear(); - } - - var totalElapsedTime = new List(); - var table = GetTable(); - - await AnsiConsole.Live(table) - .AutoClear(false) - .Overflow(configuration.VerticalOverflow) - .Cropping(configuration.VerticalOverflowCropping) - .StartAsync(async ctx => - { - var sw = new Stopwatch(); - foreach (Type problemType in LoadAllProblems(Assembly.GetEntryAssembly()!)) - { - sw.Restart(); - var potentialProblem = Activator.CreateInstance(problemType); - sw.Stop(); - - if (potentialProblem is BaseProblem problem) - { - totalElapsedTime.Add(await SolveProblem(problem, table, CalculateElapsedMilliseconds(sw), configuration)); - ctx.Refresh(); - } - } - }); - - RenderOverallResultsPanel(totalElapsedTime, configuration); - } - - #endregion - /// /// Loads all in the given assembly /// diff --git a/tests/AoCHelper.Test/SolverTest.cs b/tests/AoCHelper.Test/SolverTest.cs index 73ca2da..66c1c05 100644 --- a/tests/AoCHelper.Test/SolverTest.cs +++ b/tests/AoCHelper.Test/SolverTest.cs @@ -57,14 +57,12 @@ public async Task Solve() await Solver.Solve(); await Solver.Solve(_ => { }); await Solver.Solve(options: null); - await Solver.Solve(new SolverConfiguration()); } [Fact] public async Task SolveIntParams() { await Solver.Solve(options: null, 1, 2); - await Solver.Solve(new SolverConfiguration(), 1, 2); } [Fact] @@ -72,16 +70,13 @@ public async Task SolveIntEnumerable() { await Solver.Solve(new List { 1, 2 }); await Solver.Solve(new List { 1, 2 }, _ => { }); - await Solver.Solve(new List { 1, 2 }, new SolverConfiguration()); } [Fact] public async Task SolveTypeParams() { await Solver.Solve(_ => { }, typeof(Problem66)); - await Solver.Solve(configuration: null, typeof(Problem66)); await Solver.Solve(options: null, typeof(Problem66)); - await Solver.Solve(new SolverConfiguration(), typeof(Problem66)); } [Fact] @@ -89,7 +84,6 @@ public async Task SolveTypeEnumerable() { await Solver.Solve(new List { typeof(Problem66) }); await Solver.Solve(new List { typeof(Problem66) }, _ => { }); - await Solver.Solve(new List { typeof(Problem66) }, new SolverConfiguration()); } /// @@ -100,7 +94,6 @@ public async Task SolveLast() { await Solver.SolveLast(); await Solver.SolveLast(_ => { }); - await Solver.SolveLast(new SolverConfiguration()); } /// @@ -111,7 +104,6 @@ public async Task SolveAll() { await Solver.SolveAll(); await Solver.SolveAll(_ => { }); - await Solver.SolveAll(new SolverConfiguration()); } [Fact]