public BindingProcessImpl(IHost host, BindCommandArgs bindingArgs, ISolutionBindingOperation solutionBindingOperation, INuGetBindingOperation nugetBindingOperation, IUnboundProjectFinder unboundProjectFinder, IBindingConfigProvider bindingConfigProvider, SonarLintMode bindingMode, bool isFirstBinding = false) { this.host = host ?? throw new ArgumentNullException(nameof(host)); this.bindingArgs = bindingArgs ?? throw new ArgumentNullException(nameof(bindingArgs)); this.solutionBindingOperation = solutionBindingOperation ?? throw new ArgumentNullException(nameof(solutionBindingOperation)); this.NuGetBindingOperation = nugetBindingOperation ?? throw new ArgumentNullException(nameof(nugetBindingOperation)); this.unboundProjectFinder = unboundProjectFinder ?? throw new ArgumentNullException(nameof(unboundProjectFinder)); this.bindingConfigProvider = bindingConfigProvider ?? throw new ArgumentNullException(nameof(bindingConfigProvider)); this.bindingMode = bindingMode; Debug.Assert(bindingArgs.ProjectKey != null); Debug.Assert(bindingArgs.ProjectName != null); Debug.Assert(bindingArgs.Connection != null); this.projectSystem = this.host.GetService <IProjectSystemHelper>(); this.projectSystem.AssertLocalServiceIsNotNull(); this.InternalState = new BindingProcessState(isFirstBinding); }
public ErrorListInfoBarController(IHost host, IUnboundProjectFinder unboundProjectFinder) { if (host == null) { throw new ArgumentNullException(nameof(host)); } if (unboundProjectFinder == null) { throw new ArgumentNullException(nameof(unboundProjectFinder)); } this.host = host; this.unboundProjectFinder = unboundProjectFinder; this.configProvider = host.GetService <IConfigurationProvider>(); this.configProvider.AssertLocalServiceIsNotNull(); }
internal /* for testing purposes */ static Project[] GetProjectsForRulesetBinding(bool isFirstBinding, Project[] allSupportedProjects, IUnboundProjectFinder unboundProjectFinder, ILogger logger) { // If we are already bound we don't need to update/create rulesets in projects // that already have the ruleset information configured var projectsToUpdate = allSupportedProjects; if (isFirstBinding) { logger.WriteLine(Strings.Bind_Ruleset_InitialBinding); } else { var unboundProjects = unboundProjectFinder.GetUnboundProjects()?.ToArray() ?? new Project[] { }; projectsToUpdate = projectsToUpdate.Intersect(unboundProjects).ToArray(); var upToDateProjects = allSupportedProjects.Except(unboundProjects); if (upToDateProjects.Any()) { logger.WriteLine(Strings.Bind_Ruleset_SomeProjectsDoNotNeedToBeUpdated); var projectList = string.Join(", ", upToDateProjects.Select(p => p.Name)); logger.WriteLine($" {projectList}"); } else { logger.WriteLine(Strings.Bind_Ruleset_AllProjectsNeedToBeUpdated); } } return(projectsToUpdate); }