From 6467b0edda622d5d623b718297286048cfc2c977 Mon Sep 17 00:00:00 2001 From: Mark Ridgwell Date: Sun, 24 Dec 2023 17:13:26 +0000 Subject: [PATCH] Passed in ICheckConfigutration into the check runner --- CHANGELOG.md | 2 ++ src/FunFair.BuildCheck.Runner/CheckRunner.cs | 15 +++++---------- src/FunFair.BuildCheck/Program.cs | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f101bf..460670f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/FunFair.BuildCheck.Runner/CheckRunner.cs b/src/FunFair.BuildCheck.Runner/CheckRunner.cs index 0c76be84..2d5af3c2 100644 --- a/src/FunFair.BuildCheck.Runner/CheckRunner.cs +++ b/src/FunFair.BuildCheck.Runner/CheckRunner.cs @@ -19,20 +19,20 @@ public static class CheckRunner private static readonly Regex ProjectReferenceRegex = SourceGenerated.ProjectReferenceRegex(); public static async ValueTask CheckAsync(string solutionFileName, - bool preReleaseBuild, bool warningsAsErrors, IFrameworkSettings frameworkSettings, IProjectClassifier projectClassifier, + ICheckConfiguration checkConfiguration, Func buildServiceProvider, ILogger logger, CancellationToken cancellationToken) { IReadOnlyList 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); @@ -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 projectChecks, - SolutionProject project, - string projectFolder, - XmlDocument doc, - CancellationToken cancellationToken) + private static async ValueTask TestProjectAsync(IReadOnlyList projectChecks, SolutionProject project, string projectFolder, XmlDocument doc, CancellationToken cancellationToken) { foreach (IProjectCheck check in projectChecks) { @@ -102,10 +98,10 @@ private static async ValueTask TestProjectAsync(IReadOnlyList pro } private static IServiceProvider Setup(bool warningsAsErrors, - bool preReleaseBuild, IReadOnlyList projects, IFrameworkSettings frameworkSettings, IProjectClassifier projectClassifier, + ICheckConfiguration checkConfiguration, Func buildServiceProvider, ILogger logger) { @@ -121,8 +117,7 @@ private static IServiceProvider Setup(bool warningsAsErrors, .AddSingleton() .SetupSolutionChecks() .SetupProjectChecks(repositorySettings: wrappedRepositorySettings) - .AddSingleton( - new CheckConfiguration(preReleaseBuild: preReleaseBuild, allowPackageVersionMismatch: false))); + .AddSingleton(checkConfiguration)); } private static async ValueTask> LoadProjectsAsync(string solution, CancellationToken cancellationToken) diff --git a/src/FunFair.BuildCheck/Program.cs b/src/FunFair.BuildCheck/Program.cs index aadc9279..33123aef 100644 --- a/src/FunFair.BuildCheck/Program.cs +++ b/src/FunFair.BuildCheck/Program.cs @@ -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; @@ -55,10 +56,10 @@ public static async Task 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);