Beispiel #1
0
        public SolutionBindingOperation(IServiceProvider serviceProvider, ConnectionInformation connection, string ProjectKey, SonarLintMode bindingMode)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

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

            if (string.IsNullOrWhiteSpace(ProjectKey))
            {
                throw new ArgumentNullException(nameof(ProjectKey));
            }

            bindingMode.ThrowIfNotConnected();

            this.serviceProvider = serviceProvider;
            this.connection      = connection;
            this.ProjectKey      = ProjectKey;

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

            this.sourceControlledFileSystem = this.serviceProvider.GetService <ISourceControlledFileSystem>();
            this.sourceControlledFileSystem.AssertLocalServiceIsNotNull();

            this.bindingMode = bindingMode;
        }
        internal SolutionBindingOperation(IServiceProvider serviceProvider,
                                          ConnectionInformation connection,
                                          string projectKey,
                                          string projectName,
                                          SonarLintMode bindingMode,
                                          ILogger logger,
                                          IFileSystem fileSystem)
        {
            if (string.IsNullOrWhiteSpace(projectKey))
            {
                throw new ArgumentNullException(nameof(projectKey));
            }

            bindingMode.ThrowIfNotConnected();

            this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.connection      = connection ?? throw new ArgumentNullException(nameof(connection));
            this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
            this.fileSystem      = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));

            this.projectKey  = projectKey;
            this.projectName = projectName;
            this.bindingMode = bindingMode;

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

            this.sourceControlledFileSystem = this.serviceProvider.GetService <ISourceControlledFileSystem>();
            this.sourceControlledFileSystem.AssertLocalServiceIsNotNull();
        }
Beispiel #3
0
        public string CalculateSolutionSonarQubeRuleSetFilePath(string ProjectKey, Language language, SonarLintMode bindingMode)
        {
            if (string.IsNullOrWhiteSpace(ProjectKey))
            {
                throw new ArgumentNullException(nameof(ProjectKey));
            }

            if (language == null)
            {
                throw new ArgumentOutOfRangeException(nameof(language));
            }

            bindingMode.ThrowIfNotConnected();

            string ruleSetDirectoryRoot = this.GetSolutionSonarQubeRulesFolder(bindingMode);

            if (string.IsNullOrWhiteSpace(ruleSetDirectoryRoot))
            {
                throw new InvalidOperationException(Strings.SolutionIsClosed);
            }

            string fileNameSuffix = language.Id;

            return(GenerateSolutionRuleSetPath(ruleSetDirectoryRoot, ProjectKey, fileNameSuffix));
        }
Beispiel #4
0
        public string GetSolutionSonarQubeRulesFolder(SonarLintMode bindingMode)
        {
            bindingMode.ThrowIfNotConnected();

            var    projectSystem    = this.serviceProvider.GetService <IProjectSystemHelper>();
            string solutionFullPath = projectSystem.GetCurrentActiveSolution()?.FullName;

            // Solution closed?
            if (string.IsNullOrWhiteSpace(solutionFullPath))
            {
                return(null);
            }

            string solutionRoot         = Path.GetDirectoryName(solutionFullPath);
            string ruleSetDirectoryRoot = Path.Combine(solutionRoot,
                                                       bindingMode == SonarLintMode.LegacyConnected ?
                                                       Constants.LegacySonarQubeManagedFolderName :
                                                       Constants.SonarlintManagedFolderName);

            return(ruleSetDirectoryRoot);
        }
        internal SolutionBindingOperation(IServiceProvider serviceProvider,
                                          SonarLintMode bindingMode,
                                          IProjectBinderFactory projectBinderFactory,
                                          ILegacyConfigFolderItemAdder legacyConfigFolderItemAdder,
                                          IFileSystem fileSystem)
        {
            bindingMode.ThrowIfNotConnected();

            serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.legacyConfigFolderItemAdder = legacyConfigFolderItemAdder ?? throw new ArgumentNullException(nameof(legacyConfigFolderItemAdder));
            this.fileSystem           = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
            this.projectBinderFactory = projectBinderFactory ?? throw new ArgumentNullException(nameof(projectBinderFactory));

            this.bindingMode = bindingMode;

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

            this.sourceControlledFileSystem = serviceProvider.GetService <ISourceControlledFileSystem>();
            this.sourceControlledFileSystem.AssertLocalServiceIsNotNull();
        }