Skip to content

Commit

Permalink
Collapse slashes in directory name
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Apr 19, 2024
1 parent 085ba1f commit 087d429
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Compilers/Core/Portable/CommandLine/AnalyzerConfigSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,14 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath)

var sectionKey = _sectionKeyPool.Allocate();

var normalizedPath = PathUtilities.NormalizeWithForwardSlash(sourcePath);
normalizedPath = PathUtilities.ExpandAbsolutePathWithRelativeParts(normalizedPath);
// Note: GetDirectoryName collapses multiple slashes into a single slash and hence
// makes the path consistent and comparable with AnalyzerConfig.NormalizedDirectory
// which normalizes the directory path similarly.
var normalizedDirectory = sourcePath.Length == 0 ? sourcePath : Path.GetDirectoryName(sourcePath) ?? sourcePath;
normalizedDirectory = PathUtilities.NormalizeWithForwardSlash(normalizedDirectory);
normalizedDirectory = PathUtilities.ExpandAbsolutePathWithRelativeParts(normalizedDirectory);

var normalizedPath = PathUtilities.EnsureTrailingSeparator(normalizedDirectory) + Path.GetFileName(sourcePath);

// If we have a global config, add any sections that match the full path. We can have at most one section since
// we would have merged them earlier.
Expand Down

0 comments on commit 087d429

Please sign in to comment.