-
Notifications
You must be signed in to change notification settings - Fork 93
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
Compare file paths in platform-appropriate way #2143
Comments
I don't believe a platform setting will help here. You can mount an NTFS volume as case-sensitive. In Windows 10 you can configure arbitrary directories as case-sensitive.
@GabeDeBacker @roywill any advice on this problem? Even without any directory information on this setting, perhaps a consumer could handle all operations as case-sensitive unless/until it's time to resolve a file path on disk (at which point, the case-sensitivity of the directory could be retrieved to help with name comparisons). |
Cursory research lead me to this: dotnet/runtime#15162 which leads to an open issue dotnet/runtime#14321. In short, even |
All right. Followed up offline with @roywill and here's the strat:
In cases where the Win32 aren't available, we are running on a .NET core *NIX system and should consistently apply case-sensitive matches. As @lgolding suggests, a nice helper in the SDK would be good. From here, we need a fairly detailed scrub of path comparisons across the SDK itself to find places where utilizing the new API is necessary. |
I'd like to understand if this will address the scenario (which I didn't originally explain) that prompted me to file this issue: I have a SARIF file with a result, and the result offers a fix as follows: {
"results": [
{
"ruleId": "TEST1001",
"message": {
"text": "Something happened."
},
"locations": [
{
"artifactLocation": {
"uri": "file.c",
"uriBaseId": "SRCROOT"
},
"region": {
}
}
],
"fixes": [
{
"description": {
"text": "Fix the problem."
},
"artifactLocation": {
"uri": "File.c",
"uriBaseId": "SRCROOT"
},
"replacements": [
]
}
]
}
]
} Note that the error was detected in It's important to know that, not only because we have to make sure we're applying the fix in the right place, but also because -- at least for now -- the VS Viewer extension will only offer to apply a fix -- that is, it will only display the fix in a light bulb -- if all the replacements are in the same file you're currently editing (the one in which you clicked the light bulb). (There's nothing fundamental about that restriction. We just haven't thought about the user experience when multiple files are affected.) I guess the viewer could call into the SDK helper twice, and it would try to open both files, and determine if they are the same. There would need to be a way to ask the helper that question. |
Also, you might well ask why on earth a tool would have two different casings for the same file. Maybe the person who wrote the fixes code isn't the same as the person who wrote the results code. Also, there are possibly ways out, for example, if both |
We'd follow the algorithm in this case, look for File.c on disk, verify that it can be opened, retrieve the canonical file name from disk, and consult with VS to see if it's open in the IDE. I assume that VS honors the FS casing. This is a confusing topic, so if you'd prefer to discuss offline, let's do that. |
Windows file paths comparisons are case-insensitive; Unix file path comparisons are case-sensitive. Throughout the code we explicitly compare file paths with
StringComparison.OrdinalIgnoreCase
.Possible approach: Provide a static class
PlatformInformation
with a propertyFilePathComparison
In all file path comparisons, use
PlatformInformation.FilePathComparison
instead ofStringComparison.OrdinalIgnoreCase
.Other SARIF consumers (such as the VS Viewer extension, which is where I ran into this for the n+1st time) should use whatever facility the SDK provides.
@michaelcfanning
The text was updated successfully, but these errors were encountered: