in src/Sarif.Viewer.VisualStudio.Core/CodeAnalysisResultManager.cs [887:939]
internal bool TryResolveFilePathFromSourceControl(IList<VersionControlDetails> sources, string pathFromLogFile, string workingDirectory, IFileSystem fileSystem, out string resolvedPath)
{
if (!SarifViewerPackage.IsUnitTesting)
{
#pragma warning disable VSTHRD108 // Assert thread affinity unconditionally
ThreadHelper.ThrowIfNotOnUIThread();
#pragma warning restore VSTHRD108
}
resolvedPath = null;
if (sources == null || !sources.Any())
{
return false;
}
foreach (VersionControlDetails versionControl in sources)
{
string localFilePath;
// check if file exists in mapped location
Uri mapToPath = versionControl.MappedTo?.Uri;
if (mapToPath != null)
{
localFilePath = new Uri(mapToPath, pathFromLogFile).LocalPath;
if (fileSystem.FileExists(localFilePath))
{
resolvedPath = localFilePath;
return true;
}
}
// try to read from remote repo
Uri soureFileFromRepo = null;
string localRelativePath = null;
if (VersionControlParserFactory.TryGetVersionControlParser(versionControl, out IVersionControlParser parser))
{
soureFileFromRepo = parser.GetSourceFileUri(pathFromLogFile);
localRelativePath = parser.GetLocalRelativePath(soureFileFromRepo, pathFromLogFile);
}
if (soureFileFromRepo != null)
{
localFilePath = this.HandleHttpFileDownloadRequest(soureFileFromRepo, workingDirectory, localRelativePath);
if (fileSystem.FileExists(localFilePath))
{
resolvedPath = localFilePath;
return true;
}
}
}
return false;
}