Data-only class that references the fixed RuleSet and has the list of fixes applied to get it into that state
        private void WriteFixSummaryToOutputWindow(Dictionary <RuleSetInformation, FixedRuleSetInfo> fixMap)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine();
            foreach (var keyValue in fixMap)
            {
                RuleSetInformation ruleSetInfo = keyValue.Key;
                FixedRuleSetInfo   fixInfo     = keyValue.Value;

                builder.AppendFormat(Strings.ConflictFixHeader, ruleSetInfo.RuleSetProjectFullName, CreateCommaSeparatedString(ruleSetInfo.ConfigurationContexts));
                builder.AppendLine();
                WriteSummaryInformation(fixInfo, builder);
            }

            VsShellUtils.WriteToSonarLintOutputPane(this.host, builder.ToString());
        }
        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");
                }
            }
        }
        private static void WriteSummaryInformation(FixedRuleSetInfo fixInfo, StringBuilder output)
        {
            if (fixInfo.IncludesReset.Any())
            {
                output.Append(Indent);
                output.AppendFormat(Strings.ConflictFixResetInclude, CreateSemicolonSeparatedString(fixInfo.IncludesReset));
                output.AppendLine();
            }

            if (fixInfo.RulesDeleted.Any())
            {
                output.Append(Indent);
                output.AppendFormat(Strings.ConflictFixRulesDeleted, fixInfo.FixedRuleSet.FilePath);
                output.AppendLine();
                foreach (string ruleId in fixInfo.RulesDeleted)
                {
                    output.Append(Indent).Append(Indent);
                    output.AppendLine(ruleId);
                }
            }
        }
 private static void VerifyFix(FixedRuleSetInfo fixedInfo, int expectedIncludesReset, int expectedRulesDeleted)
 {
     Assert.AreEqual(expectedIncludesReset, fixedInfo.IncludesReset.Count(), "Unexpected number if includes were reset");
     Assert.AreEqual(expectedRulesDeleted, fixedInfo.RulesDeleted.Count(), "Unexpected number of rules were deleted");
 }