-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make matching case insensitive regardless of OS Fixes #5749 #5888
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -735,19 +735,21 @@ internal static string GetFullPathNoThrow(string path) | |||||
/// <param name="first"></param> | ||||||
/// <param name="second"></param> | ||||||
/// <param name="currentDirectory"></param> | ||||||
/// <param name="alwaysIgnoreCase"></param> | ||||||
/// <returns></returns> | ||||||
internal static bool ComparePathsNoThrow(string first, string second, string currentDirectory) | ||||||
internal static bool ComparePathsNoThrow(string first, string second, string currentDirectory, bool alwaysIgnoreCase = false) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Not sure why it's 'always'IgnoreCase
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer alwaysIgnoreCase because putting |
||||||
{ | ||||||
StringComparison pathComparison = alwaysIgnoreCase ? StringComparison.OrdinalIgnoreCase : PathComparison; | ||||||
// perf: try comparing the bare strings first | ||||||
if (string.Equals(first, second, PathComparison)) | ||||||
if (string.Equals(first, second, pathComparison)) | ||||||
{ | ||||||
return true; | ||||||
} | ||||||
|
||||||
var firstFullPath = NormalizePathForComparisonNoThrow(first, currentDirectory); | ||||||
var secondFullPath = NormalizePathForComparisonNoThrow(second, currentDirectory); | ||||||
|
||||||
return string.Equals(firstFullPath, secondFullPath, PathComparison); | ||||||
return string.Equals(firstFullPath, secondFullPath, pathComparison); | ||||||
} | ||||||
|
||||||
/// <summary> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we account for ignoring case here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely. The beautiful (terrible?) part is that it already ignored case:
https://github.com/dotnet/msbuild/blob/master/src/Shared/FileMatcher.cs#L51
I can add a test for that, though.