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);
        }
示例#2
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));
        }