Ejemplo n.º 1
0
        private WriteSettings?GetWriteSettings(BindingConfiguration configuration)
        {
            var writeSettings = new WriteSettings();

            switch (configuration.Mode)
            {
            case SonarLintMode.LegacyConnected:
            {
                writeSettings.ConfigPath            = legacyPathProvider.Get();
                writeSettings.OnSuccessfulFileWrite = legacyPostSaveOperation.OnSuccessfulSave;
                break;
            }

            case SonarLintMode.Connected:
            {
                writeSettings.ConfigPath            = connectedModePathProvider.Get();
                writeSettings.OnSuccessfulFileWrite = s => true;
                break;
            }

            case SonarLintMode.Standalone:
            {
                throw new InvalidOperationException(Strings.Bind_CannotSaveStandaloneConfiguration);
            }

            default:
            {
                Debug.Fail("Unrecognized write mode " + configuration.Mode);
                return(null);
            }
            }

            return(writeSettings);
        }
        public bool WriteConfiguration(BindingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            data = configuration;
            return(true);
        }
        public BindingConfiguration GetConfiguration()
        {
            var project = legacySerializer.ReadSolutionBinding();

            if (project != null)
            {
                return(BindingConfiguration.CreateBoundConfiguration(project, isLegacy: true));
            }

            return(wrappedProvider.GetConfiguration());
        }
Ejemplo n.º 4
0
        public bool WriteConfiguration(BindingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var writeSettings = GetWriteSettings(configuration);

            return(writeSettings.HasValue &&
                   solutionBindingSerializer.Write(writeSettings?.ConfigPath, configuration.Project, writeSettings?.OnSuccessfulFileWrite));
        }
Ejemplo n.º 5
0
        private BindingConfiguration TryGetBindingConfiguration(string bindingPath, SonarLintMode sonarLintMode)
        {
            if (bindingPath == null)
            {
                return(null);
            }

            var boundProject = solutionBindingSerializer.Read(bindingPath);

            return(boundProject == null
                ? null
                : BindingConfiguration.CreateBoundConfiguration(boundProject, sonarLintMode));
        }
Ejemplo n.º 6
0
        public BindingConfiguration GetConfiguration()
        {
            var project = legacySerializer.ReadSolutionBinding();

            if (project != null)
            {
                var config = BindingConfiguration.CreateBoundConfiguration(project, isLegacy: true);

                // Make sure the new config has the same value
                wrappedProvider.WriteConfiguration(config);
                return(config);
            }

            return(wrappedProvider.GetConfiguration());
        }
        public BindingConfiguration GetConfiguration()
        {
            var project = legacySerializer.ReadSolutionBinding();

            if (project != null)
            {
                return(BindingConfiguration.CreateBoundConfiguration(project, isLegacy: true));
            }

            project = newConnectedModeSerializer.ReadSolutionBinding();
            if (project != null)
            {
                return(BindingConfiguration.CreateBoundConfiguration(project, isLegacy: false));
            }

            return(BindingConfiguration.Standalone);
        }
Ejemplo n.º 8
0
        private BindingConfiguration TryGetBindingConfiguration(string bindingPath, SonarLintMode sonarLintMode)
        {
            if (bindingPath == null)
            {
                return(null);
            }

            var boundProject = solutionBindingDataReader.Read(bindingPath);

            if (boundProject == null)
            {
                return(null);
            }

            var bindingConfigDirectory = Path.GetDirectoryName(bindingPath);

            return(BindingConfiguration.CreateBoundConfiguration(boundProject, sonarLintMode, bindingConfigDirectory));
        }
Ejemplo n.º 9
0
        internal /* for testing */ void SaveBindingInfo(IProgressController controller, IProgressStepExecutionEvents notifications, CancellationToken token)
        {
            notifications.ProgressChanged(Strings.StartedSolutionBindingWorkflow);
            notifications.ProgressChanged(Strings.Bind_SavingBindingConfiguration);

            var connInfo = this.bindingArgs.Connection;
            BasicAuthCredentials credentials = connInfo.UserName == null ? null : new BasicAuthCredentials(connInfo.UserName, connInfo.Password);

            var boundProject = new BoundSonarQubeProject(connInfo.ServerUri, this.bindingArgs.ProjectKey, credentials, connInfo.Organization);
            var config       = BindingConfiguration.CreateBoundConfiguration(boundProject, false);

            if (this.writer.WriteConfiguration(config))
            {
                notifications.ProgressChanged(Strings.FinishedSolutionBindingWorkflowSuccessful);
            }
            else
            {
                this.host.Logger.WriteLine(Strings.Bind_FailedToSaveConfiguration);
                AbortWorkflow(controller, token);
            }
        }
Ejemplo n.º 10
0
        public bool WriteConfiguration(BindingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            // For legacy mode, we need to write the configuration to
            // disk, as well as storing it in the in-memory provider
            if (configuration.Mode == SonarLintMode.LegacyConnected)
            {
                bool success = legacySerializer.WriteSolutionBinding(configuration.Project) != null;
                if (success)
                {
                    wrappedProvider.WriteConfiguration(configuration);
                }
                return(success);
            }

            return(wrappedProvider.WriteConfiguration(configuration));
        }
        public bool WriteConfiguration(BindingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            switch (configuration.Mode)
            {
            case SonarLintMode.LegacyConnected:
                return(legacySerializer.WriteSolutionBinding(configuration.Project) != null);

            case SonarLintMode.Connected:
            case SonarLintMode.Standalone:
                return(wrappedProvider.WriteConfiguration(configuration));

            default:
                Debug.Fail("Unrecognised write mode");
                return(false);
            }
        }
        public bool WriteConfiguration(BindingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            switch (configuration.Mode)
            {
            case SonarLintMode.LegacyConnected:
                return(legacySerializer.WriteSolutionBinding(configuration.Project) != null);

            case SonarLintMode.Connected:
                return(newConnectedModeSerializer.WriteSolutionBinding(configuration.Project) != null);

            case SonarLintMode.Standalone:
                throw new InvalidOperationException(Strings.Bind_CannotSaveStandaloneConfiguration);

            default:
                Debug.Fail("Unrecognised write mode");
                return(false);
            }
        }
        private BindingConfiguration CreateBindingConfiguration(string bindingPath, BoundSonarQubeProject boundProject, SonarLintMode sonarLintMode)
        {
            var bindingConfigDirectory = Path.GetDirectoryName(bindingPath);

            return(BindingConfiguration.CreateBoundConfiguration(boundProject, sonarLintMode, bindingConfigDirectory));
        }
 public void DeleteConfiguration()
 {
     data = BindingConfiguration.Standalone;
 }