Solution level binding by delegating some of the work to ProjectBindingOperation
Inheritance: ISolutionRuleStore
        public BindingWorkflow(IHost host, BindCommandArgs bindingArgs)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (bindingArgs == null)
            {
                throw new ArgumentNullException(nameof(bindingArgs));
            }
            Debug.Assert(bindingArgs.ProjectKey != null);
            Debug.Assert(bindingArgs.ProjectName != null);
            Debug.Assert(bindingArgs.Connection != null);

            this.host          = host;
            this.bindingArgs   = bindingArgs;
            this.projectSystem = this.host.GetService <IProjectSystemHelper>();
            this.projectSystem.AssertLocalServiceIsNotNull();

            this.solutionBindingOperation = new SolutionBindingOperation(
                this.host,
                this.bindingArgs.Connection,
                this.bindingArgs.ProjectKey);
        }
        public BindingWorkflow(IHost host, ConnectionInformation connectionInformation, SonarQubeProject project)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (connectionInformation == null)
            {
                throw new ArgumentNullException(nameof(connectionInformation));
            }

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            this.host = host;
            this.connectionInformation = connectionInformation;
            this.project       = project;
            this.projectSystem = this.host.GetService <IProjectSystemHelper>();
            this.projectSystem.AssertLocalServiceIsNotNull();

            this.solutionBindingOperation = new SolutionBindingOperation(
                this.host,
                this.connectionInformation,
                this.project.Key);
        }
        public BindingWorkflow(IHost host, ConnectionInformation connectionInformation, ProjectInformation project)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (connectionInformation == null)
            {
                throw new ArgumentNullException(nameof(connectionInformation));
            }

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            this.host = host;
            this.connectionInformation = connectionInformation;
            this.project = project;
            this.projectSystem = this.host.GetService<IProjectSystemHelper>();
            this.projectSystem.AssertLocalServiceIsNotNull();

            this.solutionBindingOperation = new SolutionBindingOperation(
                    this.host,
                    this.connectionInformation,
                    this.project.Key);
        }
        public void SolutionBindingOperation_ArgChecks()
        {
            var connectionInformation = new ConnectionInformation(new Uri("http://valid"));
            Exceptions.Expect<ArgumentNullException>(() => new SolutionBindingOperation(null, connectionInformation, "key"));
            Exceptions.Expect<ArgumentNullException>(() => new SolutionBindingOperation(this.serviceProvider, null, "key"));
            Exceptions.Expect<ArgumentNullException>(() => new SolutionBindingOperation(this.serviceProvider, connectionInformation, null));
            Exceptions.Expect<ArgumentNullException>(() => new SolutionBindingOperation(this.serviceProvider, connectionInformation, string.Empty));

            var testSubject = new SolutionBindingOperation(this.serviceProvider, connectionInformation, "key");
            Assert.IsNotNull(testSubject, "Avoid 'testSubject' not used analysis warning");
        }
        internal static /* for testing purposes */ IBindingProcess CreateBindingProcess(IHost host, BindCommandArgs bindingArgs)
        {
            // Choose the type of binding
            var configProvider = host.GetService <IConfigurationProvider>();

            configProvider.AssertLocalServiceIsNotNull();

            var currentConfiguration = configProvider.GetConfiguration();

            SonarLintMode          modeToBind;
            INuGetBindingOperation nugetBindingOp;

            // If we are currently in standalone then the project is being bound for the first time.
            // Otherwise, we are updating an existing binding
            var isFirstBinding = currentConfiguration.Mode == SonarLintMode.Standalone;

            if (currentConfiguration.Mode == SonarLintMode.LegacyConnected)
            {
                host.Logger.WriteLine(Strings.Bind_UpdatingLegacyBinding);
                modeToBind     = SonarLintMode.LegacyConnected;
                nugetBindingOp = new NuGetBindingOperation(host, host.Logger);
            }
            else
            {
                host.Logger.WriteLine(
                    isFirstBinding ?
                    Strings.Bind_FirstTimeBinding :
                    Strings.Bind_UpdatingNewStyleBinding);

                modeToBind     = SonarLintMode.Connected;
                nugetBindingOp = new NoOpNuGetBindingOperation(host.Logger);
            }

            var solutionBindingOp = new SolutionBindingOperation(
                host,
                bindingArgs.Connection,
                bindingArgs.ProjectKey,
                bindingArgs.ProjectName,
                modeToBind,
                host.Logger);

            var unboundProjectFinder = new UnboundProjectFinder(host);

            var dotNetConfigProvider = new DotNetBindingConfigProvider(host.SonarQubeService, nugetBindingOp,
                                                                       bindingArgs.Connection.ServerUri.ToString(), bindingArgs.ProjectName,
                                                                       host.Logger);

            var cppConfigProvider  = new CFamilyBindingConfigProvider(host.SonarQubeService, host.Logger);
            var ruleConfigProvider = new CompositeBindingConfigProvider(dotNetConfigProvider, cppConfigProvider);

            var bindingProcess = new BindingProcessImpl(host, bindingArgs, solutionBindingOp, nugetBindingOp, unboundProjectFinder, ruleConfigProvider, isFirstBinding);

            return(bindingProcess);
        }
Exemple #6
0
        internal static /* for testing purposes */ IBindingWorkflow CreateBindingWorkflow(IHost host, BindCommandArgs bindingArgs)
        {
            //Choose the type of binding
            var configProvider = host.GetService <IConfigurationProvider>();

            configProvider.AssertLocalServiceIsNotNull();

            var currentConfiguration = configProvider.GetConfiguration();

            SonarLintMode          modeToBind;
            INuGetBindingOperation nugetBindingOp;

            // If we are currently in standalone then the project is being bound for the first time.
            // Otherwise, we are updating an existing binding
            var isFirstBinding = currentConfiguration.Mode == SonarLintMode.Standalone;

            if (currentConfiguration.Mode == SonarLintMode.LegacyConnected)
            {
                host.Logger.WriteLine(Strings.Bind_UpdatingLegacyBinding);
                modeToBind     = SonarLintMode.LegacyConnected;
                nugetBindingOp = new NuGetBindingOperation(host, host.Logger);
            }
            else
            {
                host.Logger.WriteLine(
                    isFirstBinding ?
                    Strings.Bind_FirstTimeBinding :
                    Strings.Bind_UpdatingNewStyleBinding);

                modeToBind     = SonarLintMode.Connected;
                nugetBindingOp = new NoOpNuGetBindingOperation(host.Logger);
            }

            var solutionBindingOp = new SolutionBindingOperation(
                host,
                bindingArgs.Connection,
                bindingArgs.ProjectKey,
                bindingArgs.ProjectName,
                modeToBind,
                host.Logger);

            var bindingInformationProvider = new SolutionBindingInformationProvider(host);

            return(new BindingWorkflow(host, bindingArgs, solutionBindingOp, nugetBindingOp, bindingInformationProvider, isFirstBinding));
        }
        internal /* for testing purposes */ IBindingWorkflow CreateBindingWorkflow(BindCommandArgs bindingArgs)
        {
            //Choose the type of binding
            var configProvider = this.host.GetService <IConfigurationProvider>();

            configProvider.AssertLocalServiceIsNotNull();

            var currentConfiguration = configProvider.GetConfiguration();

            SonarLintMode          modeToBind;
            INuGetBindingOperation nugetBindingOp;

            if (currentConfiguration.Mode == SonarLintMode.LegacyConnected)
            {
                host.Logger.WriteLine(Strings.Bind_UpdatingLegacyBinding);
                modeToBind     = SonarLintMode.LegacyConnected;
                nugetBindingOp = new NuGetBindingOperation(host, host.Logger);
            }
            else
            {
                // If we are currently in standalone then the project is being bound for the first time.
                // If we are in connected mode then the binding is being updated.
                host.Logger.WriteLine(
                    currentConfiguration.Mode == SonarLintMode.Standalone ?
                    Strings.Bind_FirstTimeBinding :
                    Strings.Bind_UpdatingNewStyleBinding);

                modeToBind     = SonarLintMode.Connected;
                nugetBindingOp = new NoOpNuGetBindingOperation(host.Logger);
            }

            var solutionBindingOp = new SolutionBindingOperation(
                host,
                bindingArgs.Connection,
                bindingArgs.ProjectKey,
                modeToBind);

            return(new BindingWorkflow(host, bindingArgs, solutionBindingOp, nugetBindingOp));
        }