Skip to content

Commit

Permalink
Add SolverConfiguration (#37)
Browse files Browse the repository at this point in the history
* Add `SolverConfiguration` class as the way to modify the default `Solver` behavior, with the following public properties;
  * `bool ClearConsole`
  * `bool ShowOverallResults`
  * `string? ElapsedTimeFormatSpecifier`
* Add:
  * `Solver.Solve<TProblem>(SolverConfiguration)`
  * `Solver.SolveLast(SolverConfiguration)`
  * `Solver.Solve(IEnumerable<uint>, SolverConfiguration)`
  * `Solver.Solve(IEnumerable<Type>, SolverConfiguration)`
  * `Solver.Solve( SolverConfiguration, params uint[])`
  *  `Solver.Solve( SolverConfiguration, params Type[])`
* Deprecate (marked with `ObsoleteAttribute`, will be removed in the next major release):
  * `Solve<TProblem>(bool)`
  * `SolveLast(bool)`
  *  `Solver.Solve(params uint[])`
  * `Solver.Solve(params Type[])`
  * `Solver.ElapsedTimeFormatSpecifier `
  • Loading branch information
eduherminio authored Dec 6, 2020
1 parent 498c292 commit e3883ea
Show file tree
Hide file tree
Showing 7 changed files with 310 additions and 70 deletions.
79 changes: 79 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[*.cs]
# CS8603: Possible null reference return.
dotnet_diagnostic.CS8603.severity = error
# CS8604: Possible null reference argument.
dotnet_diagnostic.CS8604.severity = error
# CS8606: Possible null reference assignment to iteration variable
dotnet_diagnostic.CS8606.severity = error
# CS8600: Converting null literal or possible null value to non-nullable type.
dotnet_diagnostic.CS8600.severity = error
# CS8602: Dereference of a possibly null reference.
dotnet_diagnostic.CS8602.severity = error
# CS8625: Cannot convert null literal to non-nullable reference type.
dotnet_diagnostic.CS8625.severity = error
# CS8607: A possible null value may not be passed to a target marked with the [DisallowNull] attribute
dotnet_diagnostic.CS8607.severity = error
# CS8608: Nullability of reference types in type doesn't match overridden member.
dotnet_diagnostic.CS8608.severity = error
# CS8609: Nullability of reference types in return type doesn't match overridden member.
dotnet_diagnostic.CS8609.severity = error
# CS8610: Nullability of reference types in type of parameter doesn't match overridden member.
dotnet_diagnostic.CS8610.severity = error
# CS8611: Nullability of reference types in type of parameter doesn't match partial method declaration.
dotnet_diagnostic.CS8611.severity = error
# CS8612: Nullability of reference types in type doesn't match implicitly implemented member.
dotnet_diagnostic.CS8612.severity = error
# CS8613: Nullability of reference types in return type doesn't match implicitly implemented member.
dotnet_diagnostic.CS8613.severity = error
# CS8614: Nullability of reference types in type of parameter doesn't match implicitly implemented member.
dotnet_diagnostic.CS8614.severity = error
# CS8615: Nullability of reference types in type doesn't match implemented member.
dotnet_diagnostic.CS8615.severity = error
# CS8616: Nullability of reference types in return type doesn't match implemented member.
dotnet_diagnostic.CS8616.severity = error
# CS8617: Nullability of reference types in type of parameter doesn't match implemented member.
dotnet_diagnostic.CS8617.severity = error
# CS8619: Nullability of reference types in value doesn't match target type.
dotnet_diagnostic.CS8619.severity = error
#CS8620: Argument cannot be used for parameter due to differences in the nullability of reference types.
dotnet_diagnostic.CS8620.severity = error
#CS8621: Nullability of reference types in return type doesn't match the target delegate.
dotnet_diagnostic.CS8621.severity = error
#CS8622: Nullability of reference types in type of parameter doesn't match the target delegate.
dotnet_diagnostic.CS8622.severity = error
#CS8624: Argument cannot be used as an output for parameter due to differences in the nullability of reference types.
dotnet_diagnostic.CS8624.severity = error
#CS8625: Cannot convert null literal to non-nullable reference type.
dotnet_diagnostic.CS8625.severity = error
#CS8626: The 'as' operator may produce a null value for a type parameter.
dotnet_diagnostic.CS8626.severity = error
#CS8629: Nullable value type may be null.
dotnet_diagnostic.CS8629.severity = error
#CS8631: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match constraint type.
dotnet_diagnostic.CS8631.severity = error
#CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
dotnet_diagnostic.CS8632.severity = error
#CS8633: Nullability in constraints for type parameter doesn't match the constraints for type parameter in implicitly implemented interface method.
dotnet_diagnostic.CS8633.severity = error
#CS8634: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.
dotnet_diagnostic.CS8634.severity = error
#CS8638: Conditional access may produce a null value for a type parameter.
dotnet_diagnostic.CS8638.severity = error
#CS8643: Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type.
dotnet_diagnostic.CS8643.severity = error
#CS8644: Type does not implement interface member. Nullability of reference types in interface implemented by the base type doesn't match.
dotnet_diagnostic.CS8644.severity = error
#CS8645: Interface is already listed in the interface list with different nullability of reference types.
dotnet_diagnostic.CS8645.severity = error
#CS8653: A default expression introduces a null value for a type parameter.
dotnet_diagnostic.CS8653.severity = error
#CS8654: A null literal introduces a null value for a type parameter.
dotnet_diagnostic.CS8654.severity = error
#CS8655: The switch expression does not handle some null inputs.
dotnet_diagnostic.CS8655.severity = error
#CS8667: Partial method declarations have inconsistent nullability in constraints for type parameter
dotnet_diagnostic.CS8667.severity = error
#CS8714: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.
dotnet_diagnostic.CS8714.severity = error
#CS8618: Non-nullable property is uninitialized. Consider declaring the property as nullable.
dotnet_diagnostic.CS8618.severity = error
1 change: 1 addition & 0 deletions AoCHelperSolution.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VisualStudioVersion = 16.0.29318.209
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2222508E-D4AB-455E-9089-C177579ACE08}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\ci.yml = .github\workflows\ci.yml
Directory.Build.props = Directory.Build.props
.github\workflows\release.yml = .github\workflows\release.yml
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ Creating your Advent of Code repository from [AdventOfCode.Template](https://git
- Name them `DayXX` or `Day_XX` and make them inherit `BaseDay`.
- Name them `ProblemXX` or `Problem_XX`and make them inherit `BaseProblem`.
- **Put your input files under `Inputs/` directory** and follow `XX.txt` naming convention for day `XX`. Make sure to copy those files to your output folder.
- Choose your **solving strategy** in your `Main()` method:
- Choose your **solving strategy** in your `Main()` method, adjusting it with your custom `SolverConfiguration` if needed:
- `Solver.SolveAll();`
- `Solver.SolveLast();`
- `Solver.SolveLast(clearConsole: false);`
- `Solver.SolveLast(new SolverConfiguration { ClearConsole = false });`
- `Solver.Solve<Day_05>();`
- `Solver.Solve(5, 6);`
- `Solver.Solve(typeof(Day_05), typeof(Day_06));`
- `Solver.Solve(new List<uint>{ 5, 6 });`
- `Solver.Solve(new List<Type> { typeof(Day_05), typeof(Day_06) });`

## Advanced usage

Expand All @@ -58,7 +58,7 @@ You can also:
- Override `CalculateIndex()` to follow a different `XX` or `_XX` convention in your class names.
- Override `InputFilePath` to follow a different naming convention in your input files. Check the [current implementation](https://github.com/eduherminio/AoCHelper/blob/master/src/AoCHelper/BaseProblem.cs) to understand how to reuse all the other properties and methods.
- _[Not recommended]_ Override `InputFilePath` in any specific problem class to point to a concrete file. This will make the values of `ClassPrefix`, `InputFileDirPath` and `InputFileExtension` and the implementation of `CalculateIndex()` irrelevant (see the [current implementation](https://github.com/eduherminio/AoCHelper/blob/master/src/AoCHelper/BaseProblem.cs)).
- Override `Solver.ElapsedTimeFormatSpecifier` to provide custom [numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings) for the elapsed milliseconds.
- ~~Override `Solver.ElapsedTimeFormatSpecifier`~~ Configure `SolverConfiguration.ElapsedTimeFormatSpecifier` to provide custom [numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings) for the elapsed milliseconds.

## Usage examples

Expand Down
Loading

0 comments on commit e3883ea

Please sign in to comment.