EscapeFileName() public static method

Replace all invalid file path characters with the underscore ("_").
public static EscapeFileName ( string unescapedName ) : string
unescapedName string
return string
Example #1
0
        /// <summary>
        /// Generate a solution level rule set file path base on <paramref name="sonarQubeProjectKey"/> and <see cref="fileNameSuffix"/>
        /// </summary>
        /// <param name="ruleSetRootPath">Root directory to generate the full file path under</param>
        /// <param name="sonarQubeProjectKey">SonarQube project key to generate a rule set file name path for</param>
        /// <param name="fileNameSuffix">Fixed file name suffix</param>
        private static string GenerateSolutionRuleSetPath(string ruleSetRootPath, string sonarQubeProjectKey, string fileNameSuffix)
        {
            // Cannot use Path.ChangeExtension here because if the sonar project name contains
            // a dot (.) then everything after this will be replaced with .ruleset
            string fileName = $"{PathHelper.EscapeFileName(sonarQubeProjectKey + fileNameSuffix)}.{Constants.RuleSetFileExtension}";

            return(Path.Combine(ruleSetRootPath, fileName));
        }
Example #2
0
        /// <summary>
        /// Generate a solution level rule set file path base on <paramref name="ProjectKey"/> and <see cref="fileNameSuffix"/>
        /// </summary>
        /// <param name="ruleSetRootPath">Root directory to generate the full file path under</param>
        /// <param name="ProjectKey">SonarQube project key to generate a rule set file name path for</param>
        /// <param name="fileNameSuffixAndExtension">Fixed file name suffix and extension (language-specific)</param>
        private static string GenerateSolutionRuleSetPath(string ruleSetRootPath, string ProjectKey, string fileNameSuffixAndExtension)
        {
            // Cannot use Path.ChangeExtension here because if the sonar project name contains
            // a dot (.) then everything after this will be replaced with .ruleset
            string fileName = PathHelper.EscapeFileName(ProjectKey + fileNameSuffixAndExtension)
                              .ToLowerInvariant(); // Must be lower case - see https://github.com/SonarSource/sonarlint-visualstudio/issues/1068

            return(Path.Combine(ruleSetRootPath, fileName));
        }