private static RuleSetInclude AddRuleSetInclusion(RuleSet parent, RuleSet child, bool useRelativePath) { string include = useRelativePath ? PathHelper.CalculateRelativePath(parent.FilePath, child.FilePath) : child.FilePath; var ruleSetInclude = new RuleSetInclude(include, RuleAction.Default); parent.RuleSetIncludes.Add(ruleSetInclude); return(ruleSetInclude); }
[TestMethod] // Regression test for #1068: https://github.com/SonarSource/sonarlint-visualstudio/issues/1068 public void CheckSolutionRuleSet_RuleSetIncludePathFormatting() { // 1. Check the behaviour of the Microsoft.VisualStudio.CodeAnalysis.RuleSetInclude constructor // is as expected (forces path to lower case) var include = new RuleSetInclude("C:\\subDIR1\\SUBDIR2\\file.txt", RuleAction.Default); include.FilePath.Should().Be("c:\\subdir1\\subdir2\\file.txt"); include = new RuleSetInclude("..\\xxx\\SUBDIR2\\file.txt", RuleAction.Default); include.FilePath.Should().Be("..\\xxx\\subdir2\\file.txt"); // 2. Check our file name calculation function produces lower-case this.projectSystemHelper.CurrentActiveSolution = new SolutionMock(null, @"z:\folder\solution\solutionFile.sln"); string ruleSetPath = testSubject.CalculateSolutionSonarQubeRuleSetFilePath("MYKEY", new Language("l_id", "l_name", "FILESUFFIX.ANDEXT", new SonarQube.Client.Models.SonarQubeLanguage("l_server_key", "l_server_name")), SonarLintMode.Connected); ruleSetPath.Should().Be(@"z:\folder\solution\.sonarlint\mykeyfilesuffix.andext"); // should be lower-case }
private static RuleSetInclude AddRuleSetInclusion(RuleSet parent, RuleSet child, bool useRelativePath) { string include = useRelativePath ? PathHelper.CalculateRelativePath(parent.FilePath, child.FilePath) : child.FilePath; var ruleSetInclude = new RuleSetInclude(include, RuleAction.Default); parent.RuleSetIncludes.Add(ruleSetInclude); return ruleSetInclude; }