protected FileBindingSerializer(ISourceControlledFileSystem sccFileSystem, ICredentialStore store,
                                        ILogger logger, IFile fileWrapper)
        {
            if (sccFileSystem == null)
            {
                throw new ArgumentNullException(nameof(sccFileSystem));
            }
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (fileWrapper == null)
            {
                throw new ArgumentNullException(nameof(fileWrapper));
            }

            this.sccFileSystem = sccFileSystem;
            this.Store         = store;
            this.logger        = logger;
            this.fileWrapper   = fileWrapper;
        }
        public ProjectBindingOperation(IServiceProvider serviceProvider, Project project, ISolutionRuleStore ruleStore)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

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

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

            this.serviceProvider    = serviceProvider;
            this.initializedProject = project;
            this.ruleStore          = ruleStore;

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

            this.ruleSetSerializer = this.serviceProvider.GetService <IRuleSetSerializer>();
            this.ruleSetSerializer.AssertLocalServiceIsNotNull();
        }
示例#3
0
        public SolutionBindingOperation(IServiceProvider serviceProvider, ConnectionInformation connection, string sonarQubeProjectKey)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

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

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

            this.serviceProvider     = serviceProvider;
            this.connection          = connection;
            this.sonarQubeProjectKey = sonarQubeProjectKey;

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

            this.sourceControlledFileSystem = this.serviceProvider.GetService <ISourceControlledFileSystem>();
            this.sourceControlledFileSystem.AssertLocalServiceIsNotNull();
        }
        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();
        }
        public SolutionBindingOperation(IServiceProvider serviceProvider, ConnectionInformation connection, string sonarQubeProjectKey)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

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

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

            this.serviceProvider = serviceProvider;
            this.connection = connection;
            this.sonarQubeProjectKey = sonarQubeProjectKey;

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

            this.sourceControlledFileSystem = this.serviceProvider.GetService<ISourceControlledFileSystem>();
            this.sourceControlledFileSystem.AssertLocalServiceIsNotNull();
        }
示例#6
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;
        }
示例#7
0
        public string WriteSolutionBinding(BoundSonarQubeProject binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException(nameof(binding));
            }

            ISourceControlledFileSystem sccFileSystem = this.serviceProvider.GetService <ISourceControlledFileSystem>();

            sccFileSystem.AssertLocalServiceIsNotNull();

            string configFile = this.GetSonarQubeConfigurationFilePath();

            if (string.IsNullOrWhiteSpace(configFile))
            {
                return(null);
            }

            sccFileSystem.QueueFileWrite(configFile, () =>
            {
                if (this.WriteBindingInformation(configFile, binding))
                {
                    this.AddSolutionItemFile(configFile);
                    this.RemoveSolutionItemFile(configFile);
                    return(true);
                }

                return(false);
            });

            return(configFile);
        }
        public ProjectBindingOperation(IServiceProvider serviceProvider, Project project, ISolutionRuleStore ruleStore)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

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

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

            this.serviceProvider = serviceProvider;
            this.initializedProject = project;
            this.ruleStore = ruleStore;

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

            this.ruleSetSerializer = this.serviceProvider.GetService<IRuleSetSerializer>();
            this.ruleSetSerializer.AssertLocalServiceIsNotNull();
        }
 public SolutionBindingSerializer(ISourceControlledFileSystem sccFileSystem,
                                  ISolutionBindingFileLoader solutionBindingFileLoader,
                                  ISolutionBindingCredentialsLoader credentialsLoader)
 {
     this.sccFileSystem             = sccFileSystem ?? throw new ArgumentNullException(nameof(sccFileSystem));
     this.solutionBindingFileLoader = solutionBindingFileLoader ?? throw new ArgumentNullException(nameof(solutionBindingFileLoader));
     this.credentialsLoader         = credentialsLoader ?? throw new ArgumentNullException(nameof(credentialsLoader));
 }
 public ConfigurationSerializer(
     IVsSolution solution,
     ISourceControlledFileSystem sccFileSystem,
     ICredentialStore store,
     ILogger logger)
     : this(solution, sccFileSystem, store, logger, new FileWrapper())
 {
 }
示例#11
0
 internal /*for testing purposes*/ SolutionBindingSerializer(
     IServiceProvider serviceProvider,
     ISourceControlledFileSystem sccFileSystem,
     ICredentialStore store,
     ILogger logger, IFile fileWrapper)
     : base(sccFileSystem, store, logger, fileWrapper)
 {
     if (serviceProvider == null)
     {
         throw new ArgumentNullException(nameof(serviceProvider));
     }
     this.serviceProvider = serviceProvider;
 }
示例#12
0
        public ProjectBindingOperation(IServiceProvider serviceProvider, Project project, ISolutionBindingConfigFileStore configFileStore, ILogger logger)
        {
            this.serviceProvider    = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.initializedProject = project ?? throw new ArgumentNullException(nameof(project));
            this.configFileStore    = configFileStore ?? throw new ArgumentNullException(nameof(configFileStore));
            this.logger             = logger ?? throw new ArgumentNullException(nameof(logger));

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

            this.ruleSetSerializer = this.serviceProvider.GetService <IRuleSetSerializer>();
            this.ruleSetSerializer.AssertLocalServiceIsNotNull();
        }
        internal /* for testing */ ConfigurationSerializer(
            IVsSolution solution,
            ISourceControlledFileSystem sccFileSystem,
            ICredentialStore store,
            ILogger logger,
            IFile fileWrapper)
            : base(sccFileSystem, store, logger, fileWrapper)
        {
            if (solution == null)
            {
                throw new ArgumentNullException(nameof(solution));
            }

            this.solution = solution;
        }
        private void OnFixConflicts(IEnumerable <ProjectRuleSetConflict> conflicts)
        {
            if (this.OnFixConflictsStatus(conflicts))
            {
                var componentModel = host.GetService <SComponentModel, IComponentModel>();
                TelemetryLoggerAccessor.GetLogger(componentModel)?.ReportEvent(TelemetryEvent.FixConflictsCommandCalled);

                IRuleSetInspector inspector = this.host.GetService <IRuleSetInspector>();
                inspector.AssertLocalServiceIsNotNull();

                ISourceControlledFileSystem sccFileSystem = this.host.GetService <ISourceControlledFileSystem>();
                sccFileSystem.AssertLocalServiceIsNotNull();

                IRuleSetSerializer ruleSetSerializer = this.host.GetService <IRuleSetSerializer>();
                ruleSetSerializer.AssertLocalServiceIsNotNull();

                var fixedConflictsMap = new Dictionary <RuleSetInformation, FixedRuleSetInfo>();
                foreach (RuleSetInformation ruleSetInfo in conflicts.Select(c => c.RuleSetInfo))
                {
                    FixedRuleSetInfo fixInfo = inspector.FixConflictingRules(ruleSetInfo.BaselineFilePath, ruleSetInfo.RuleSetFilePath, ruleSetInfo.RuleSetDirectories);
                    Debug.Assert(fixInfo != null);

                    fixedConflictsMap[ruleSetInfo] = fixInfo;

                    sccFileSystem.QueueFileWrite(fixInfo.FixedRuleSet.FilePath, () =>
                    {
                        ruleSetSerializer.WriteRuleSetFile(fixInfo.FixedRuleSet, fixInfo.FixedRuleSet.FilePath);

                        return(true);
                    });
                }

                this.WriteFixSummaryToOutputWindow(fixedConflictsMap);

                if (sccFileSystem.WriteQueuedFiles())
                {
                    this.Clear();
                }
                else
                {
                    Debug.Fail("Failed to write one or more of the queued files");
                }
            }
        }
        internal CSharpVBBindingOperation(IServiceProvider serviceProvider,
                                          Project project,
                                          ICSharpVBBindingConfig cSharpVBBindingConfig,
                                          IFileSystem fileSystem,
                                          IAdditionalFileConflictChecker additionalFileConflictChecker,
                                          IRuleSetReferenceChecker ruleSetReferenceChecker)
        {
            this.serviceProvider               = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.initializedProject            = project ?? throw new ArgumentNullException(nameof(project));
            this.cSharpVBBindingConfig         = cSharpVBBindingConfig ?? throw new ArgumentNullException(nameof(cSharpVBBindingConfig));
            this.fileSystem                    = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
            this.additionalFileConflictChecker = additionalFileConflictChecker ?? throw new ArgumentNullException(nameof(additionalFileConflictChecker));
            this.ruleSetReferenceChecker       = ruleSetReferenceChecker ?? throw new ArgumentNullException(nameof(ruleSetReferenceChecker));

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

            this.ruleSetSerializer = this.serviceProvider.GetService <IRuleSetSerializer>();
            this.ruleSetSerializer.AssertLocalServiceIsNotNull();
        }
        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();
        }
 /// <summary>
 /// Queues a write operation for a file path. New or edit is evaluated at the time of this method execution.
 /// </summary>
 /// <param name="filePath">File path that want to write to</param>
 /// <param name="fileWriteOperation">The actual write operation, return false if failed</param>
 public static void QueueFileWrite(this ISourceControlledFileSystem sourceControlledFile, string filePath, Func <bool> fileWriteOperation)
 {
     sourceControlledFile.QueueFileWrites(new List <string> {
         filePath
     }, fileWriteOperation);
 }
 /// <summary>
 /// Returns whether the file exists on disk or in a queue to be written. <seealso cref="QueueFileWrite(ISourceControlledFileSystem,string,Func{bool})"/>
 /// </summary>
 public static bool FileExistOrQueuedToBeWritten(this ISourceControlledFileSystem sourceControlledFile, string filePath)
 {
     return(sourceControlledFile.FilesExistOrQueuedToBeWritten(new List <string> {
         filePath
     }));
 }