Skip to content

Commit

Permalink
prevent VS from crashing and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
edkazcarlson-ms committed Oct 25, 2023
1 parent 2a38c61 commit 206f6aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/Sarif.Viewer.VisualStudio.Core/ResultTextMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,15 @@ internal bool TryToFullyPopulateRegionAndFilePath()
out resolvedUri)))
{
// Fill out the region's properties
this.fullyPopulatedRegion = FileRegionsCache.Instance.PopulateTextRegionProperties(this.region, resolvedUri, populateSnippet: true);
try
{
this.fullyPopulatedRegion = FileRegionsCache.Instance.PopulateTextRegionProperties(this.region, resolvedUri, populateSnippet: true);
}
catch (ArgumentOutOfRangeException)
{
// in the case there is a mismatch between the file opened on the users device and the file used to create the insight, this can throw an error due to one being larger than the other.
return false;
}
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/Sarif.Viewer.VisualStudio.Core/Tags/SarifLocationErrorTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,18 @@ private void ApplyStylingRecurs(Block parentBlock, object obj, Brush textBrush,
/// <param name="e">The event of being clicked.</param>
private void Block_MouseDown(object sender, MouseButtonEventArgs e)
{
if (sender is Hyperlink hyperlink)
try
{
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri));
e.Handled = true;
if (sender is Hyperlink hyperlink)
{
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri));
e.Handled = true;
}
}
catch (Exception)
{
// in case that we cannot navigate to the uri for whatever reason we want to swallow as we do not want to crash VS as a whole.
Console.Write("hi");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ private void DownloadInsights(string filePath)
}
}

if (sourceControlType == SourceControlType.Unknown) // file in question is not a file that is part of a codebase, skip over.
{
return (null, null);
}

string repoRootedFilePath = GetRepoRootedFilePath(gitRepoRoot, absoluteFilePath);

if (sourceControlType == SourceControlType.Unknown)
Expand Down

0 comments on commit 206f6aa

Please sign in to comment.