Skip to content

Commit

Permalink
Move to file-scoped namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 10, 2024
1 parent c63770e commit 0be7ca2
Show file tree
Hide file tree
Showing 30 changed files with 892 additions and 867 deletions.
29 changes: 14 additions & 15 deletions src/AoCHelper.PoC.Library/LibraryDay11.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

public class LibraryDay11 : BaseLibraryDay
{
public class LibraryDay11 : BaseLibraryDay
public LibraryDay11()
{
public LibraryDay11()
if (!File.Exists(InputFilePath))
{
if (!File.Exists(InputFilePath))
{
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
}

public override ValueTask<string> Solve_1()
{
return new("Solution Library 1.1");
}
public override ValueTask<string> Solve_1()
{
return new("Solution Library 1.1");
}

public override ValueTask<string> Solve_2()
{
return new("Solution Library 1.2");
}
public override ValueTask<string> Solve_2()
{
return new("Solution Library 1.2");
}
}
31 changes: 15 additions & 16 deletions src/AoCHelper.PoC.Library/LibraryDay15.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

public class LibraryDay15 : BaseLibraryDay
{
public class LibraryDay15 : BaseLibraryDay
public LibraryDay15()
{
public LibraryDay15()
{
throw new SolvingException("Exception in constructor");
}
throw new SolvingException("Exception in constructor");
}

public override ValueTask<string> Solve_1()
{
Thread.Sleep(66);
return new("Solution Library 5.1");
}
public override ValueTask<string> Solve_1()
{
Thread.Sleep(66);
return new("Solution Library 5.1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(66);
return new("Solution Library 5.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(66);
return new("Solution Library 5.2");
}
}
21 changes: 10 additions & 11 deletions src/AoCHelper.PoC.Library/LibraryDay16.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

public class LibraryDay16 : BaseLibraryDay
{
public class LibraryDay16 : BaseLibraryDay
public override ValueTask<string> Solve_1()
{
public override ValueTask<string> Solve_1()
{
throw new SolvingException("Exception in Library 6 part 1");
}
throw new SolvingException("Exception in Library 6 part 1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(123);
return new("Solution Library 6.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(123);
return new("Solution Library 6.2");
}
}
19 changes: 9 additions & 10 deletions src/AoCHelper.PoC.Library/LibraryDay17.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

public class LibraryDay17 : BaseLibraryDay
{
public class LibraryDay17 : BaseLibraryDay
public override ValueTask<string> Solve_1()
{
public override ValueTask<string> Solve_1()
{
return new("Solution Library 7.1");
}
return new("Solution Library 7.1");
}

public override ValueTask<string> Solve_2()
{
throw new SolvingException("Exception in Library 7 part 2");
}
public override ValueTask<string> Solve_2()
{
throw new SolvingException("Exception in Library 7 part 2");
}
}
33 changes: 16 additions & 17 deletions src/AoCHelper.PoC.Library/LibraryDay_12.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

public class LibraryDay_12 : BaseLibraryDay
{
public class LibraryDay_12 : BaseLibraryDay
public LibraryDay_12()
{
public LibraryDay_12()
if (!File.Exists(InputFilePath))
{
if (!File.Exists(InputFilePath))
{
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
}

public override ValueTask<string> Solve_1()
{
Thread.Sleep(1);
return new("Solution Library 2.1");
}
public override ValueTask<string> Solve_1()
{
Thread.Sleep(1);
return new("Solution Library 2.1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(11);
return new("Solution Library 2.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(11);
return new("Solution Library 2.2");
}
}
33 changes: 16 additions & 17 deletions src/AoCHelper.PoC.Library/Problem13.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

internal class Problem13 : BaseLibraryProblem
{
internal class Problem13 : BaseLibraryProblem
public Problem13()
{
public Problem13()
if (!File.Exists(InputFilePath))
{
if (!File.Exists(InputFilePath))
{
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
}

public override ValueTask<string> Solve_1()
{
Thread.Sleep(101);
return new("Solution Library 3.1");
}
public override ValueTask<string> Solve_1()
{
Thread.Sleep(101);
return new("Solution Library 3.1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(501);
return new("Solution Library 3.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(501);
return new("Solution Library 3.2");
}
}
37 changes: 18 additions & 19 deletions src/AoCHelper.PoC.Library/Problem14.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

internal class Problem14 : BaseLibraryProblem
{
internal class Problem14 : BaseLibraryProblem
{
protected override string InputFileExtension => ".in";
protected override string InputFileExtension => ".in";

public Problem14()
public Problem14()
{
if (!File.Exists(InputFilePath))
{
if (!File.Exists(InputFilePath))
{
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
}

public override ValueTask<string> Solve_1()
{
Thread.Sleep(1500);
return new("Solution Library 4.1");
}
public override ValueTask<string> Solve_1()
{
Thread.Sleep(1500);
return new("Solution Library 4.1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(2000);
return new("Solution Library 4.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(2000);
return new("Solution Library 4.2");
}
}
47 changes: 23 additions & 24 deletions src/AoCHelper.PoC.Library/RandomProblem.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
using System.Reflection;

namespace AoCHelper.PoC.Library
namespace AoCHelper.PoC.Library;

internal class RandomProblem : BaseLibraryProblem
{
internal class RandomProblem : BaseLibraryProblem
{
/// <summary>
/// Overriding FilePath, due to problem not following any convention (not even index one).
/// </summary>
public override string InputFilePath =>
Path.Combine(
Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!,
"Inputs/LibraryRandomInput.random");
/// <summary>
/// Overriding FilePath, due to problem not following any convention (not even index one).
/// </summary>
public override string InputFilePath =>
Path.Combine(
Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!,
"Inputs/LibraryRandomInput.random");

public RandomProblem()
public RandomProblem()
{
if (!File.Exists(InputFilePath))
{
if (!File.Exists(InputFilePath))
{
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
}

public override ValueTask<string> Solve_1()
{
return new("Solution Library Random.1");
}
public override ValueTask<string> Solve_1()
{
return new("Solution Library Random.1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(10_000);
return new("Solution Library Random.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(10_000);
return new("Solution Library Random.2");
}
}
29 changes: 14 additions & 15 deletions src/AoCHelper.PoC/Day01.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
namespace AoCHelper.PoC
namespace AoCHelper.PoC;

public class Day01 : BaseDay
{
public class Day01 : BaseDay
public Day01()
{
public Day01()
if (!File.Exists(InputFilePath))
{
if (!File.Exists(InputFilePath))
{
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
throw new SolvingException($"Path {InputFilePath} not found for {GetType().Name}");
}
}

public override ValueTask<string> Solve_1()
{
return new("Solution 1.1");
}
public override ValueTask<string> Solve_1()
{
return new("Solution 1.1");
}

public override ValueTask<string> Solve_2()
{
return new("Solution 1.2");
}
public override ValueTask<string> Solve_2()
{
return new("Solution 1.2");
}
}
31 changes: 15 additions & 16 deletions src/AoCHelper.PoC/Day05.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
namespace AoCHelper.PoC
namespace AoCHelper.PoC;

public class Day05 : BaseProblem
{
public class Day05 : BaseProblem
public Day05()
{
public Day05()
{
throw new SolvingException("Exception in constructor");
}
throw new SolvingException("Exception in constructor");
}

public override ValueTask<string> Solve_1()
{
Thread.Sleep(66);
return new("Solution 5.1");
}
public override ValueTask<string> Solve_1()
{
Thread.Sleep(66);
return new("Solution 5.1");
}

public override ValueTask<string> Solve_2()
{
Thread.Sleep(66);
return new("Solution 5.2");
}
public override ValueTask<string> Solve_2()
{
Thread.Sleep(66);
return new("Solution 5.2");
}
}
Loading

0 comments on commit 0be7ca2

Please sign in to comment.