Skip to content

Commit

Permalink
Passed in ICheckConfigutration into the check runner
Browse files Browse the repository at this point in the history
  • Loading branch information
credfeto committed Dec 24, 2023
1 parent 2426853 commit 6467b0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release
### Added
### Fixed
### Changed

- Passed in ICheckConfiguration into the check runner
### Removed
### Deployment Changes

Expand Down
15 changes: 5 additions & 10 deletions src/FunFair.BuildCheck.Runner/CheckRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public static class CheckRunner
private static readonly Regex ProjectReferenceRegex = SourceGenerated.ProjectReferenceRegex();

public static async ValueTask<int> CheckAsync(string solutionFileName,
bool preReleaseBuild,
bool warningsAsErrors,
IFrameworkSettings frameworkSettings,
IProjectClassifier projectClassifier,
ICheckConfiguration checkConfiguration,
Func<IServiceCollection, IServiceProvider> buildServiceProvider,
ILogger logger,
CancellationToken cancellationToken)
{
IReadOnlyList<SolutionProject> projects = await LoadProjectsAsync(solution: solutionFileName, cancellationToken: cancellationToken);
IServiceProvider services = Setup(warningsAsErrors: warningsAsErrors,
preReleaseBuild: preReleaseBuild,
projects: projects,
frameworkSettings: frameworkSettings,
projectClassifier: projectClassifier,
checkConfiguration: checkConfiguration,
buildServiceProvider: buildServiceProvider,
logger: logger);

Expand Down Expand Up @@ -89,11 +89,7 @@ private static async ValueTask CheckProjectAsync(SolutionProject project,
await TestProjectAsync(projectChecks: projectChecks, project: project, projectFolder: projectFolder, doc: doc, cancellationToken: cancellationToken);
}

private static async ValueTask TestProjectAsync(IReadOnlyList<IProjectCheck> projectChecks,
SolutionProject project,
string projectFolder,
XmlDocument doc,
CancellationToken cancellationToken)
private static async ValueTask TestProjectAsync(IReadOnlyList<IProjectCheck> projectChecks, SolutionProject project, string projectFolder, XmlDocument doc, CancellationToken cancellationToken)
{
foreach (IProjectCheck check in projectChecks)
{
Expand All @@ -102,10 +98,10 @@ private static async ValueTask TestProjectAsync(IReadOnlyList<IProjectCheck> pro
}

private static IServiceProvider Setup(bool warningsAsErrors,
bool preReleaseBuild,
IReadOnlyList<SolutionProject> projects,
IFrameworkSettings frameworkSettings,
IProjectClassifier projectClassifier,
ICheckConfiguration checkConfiguration,
Func<IServiceCollection, IServiceProvider> buildServiceProvider,
ILogger logger)
{
Expand All @@ -121,8 +117,7 @@ private static IServiceProvider Setup(bool warningsAsErrors,
.AddSingleton<IProjectXmlLoader, ProjectXmlLoader>()
.SetupSolutionChecks()
.SetupProjectChecks(repositorySettings: wrappedRepositorySettings)
.AddSingleton<ICheckConfiguration>(
new CheckConfiguration(preReleaseBuild: preReleaseBuild, allowPackageVersionMismatch: false)));
.AddSingleton(checkConfiguration));
}

private static async ValueTask<IReadOnlyList<SolutionProject>> LoadProjectsAsync(string solution, CancellationToken cancellationToken)
Expand Down
3 changes: 2 additions & 1 deletion src/FunFair.BuildCheck/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using FunFair.BuildCheck.Helpers;
using FunFair.BuildCheck.Interfaces;
using FunFair.BuildCheck.Runner;
using FunFair.BuildCheck.Runner.Services;
using FunFair.BuildCheck.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -55,10 +56,10 @@ public static async Task<int> Main(string[] args)
IProjectClassifier projectClassifier = new ProjectClassifier();

int errors = await CheckRunner.CheckAsync(solutionFileName: solutionFileName,
preReleaseBuild: preReleaseBuild,
warningsAsErrors: warningsAsErrors,
frameworkSettings: frameworkSettings,
projectClassifier: projectClassifier,
new CheckConfiguration(preReleaseBuild: preReleaseBuild, allowPackageVersionMismatch: false),
buildServiceProvider: services => services.BuildServiceProvider(),
logger: logger,
cancellationToken: CancellationToken.None);
Expand Down

0 comments on commit 6467b0e

Please sign in to comment.