-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Respect line directives in SARIF logger #71454
Respect line directives in SARIF logger #71454
Conversation
"version": "42.42.42.42", | ||
"fileVersion": "4.9.0-dev (<developer build>)", | ||
"semanticVersion": "42.42.42", |
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.
Can't hard code these values cause they will change. Even the version will change between local and CI (-dev vs. -ci). Need to either filter these out or fill them with interpolation.
var source = $$""" | ||
public class C | ||
{ | ||
#line 123 "D:\otherfile.cs" |
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.
This makes me a bit nervous cause there are cases where #line
can behave differently if it can / can't find a file. Hard coding a path like this means it's possible on some machines the file may exist while on others it won't. Prefer instead if we definitively do / don't put a file on disk at this location via Temp.CreateDirectory().CreateFile
and then use interpolation to put the known file path.
FileLinePositionSpan span = diagnosticLocation.GetMappedLineSpan(); | ||
var path = diagnosticLocation.SourceTree is { } tree | ||
? tree.GetDisplayPath(diagnosticLocation.SourceSpan, resolver) | ||
: span.Path; |
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.
Why did you decide to use mapped paths here? Thhe mental model I had for this change is that the sarif location should match the location that we print on the command line for errors. I didn't think that we used mapped paths for that (could be wrong)
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.
I was mistaken. I had an impression that /pathmap
was used to report diagnostics on the command line. The ambiguity between "path mapping" for line directives and the command line doesn't help here.
Closes #71449