Skip to content

Commit 2f4617b

Browse files
bug fix
1 parent 3b5a28a commit 2f4617b

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

tools/extensions/CodeQL.VisualStudio/CodeQL.VisualStudio/CodeQLCommand.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
using Microsoft.VisualStudio.Shell.Interop;
1010
using Microsoft.VisualStudio.Threading;
1111
using System;
12+
using System.Collections;
1213
using System.Collections.Generic;
1314
using System.ComponentModel.Design;
1415
using System.Diagnostics;
1516
using System.Linq;
1617
using System.Linq.Expressions;
18+
using System.Reflection.Metadata;
1719
using System.Runtime.InteropServices;
1820
using System.Security.Policy;
1921
using System.Threading.Tasks;
@@ -196,8 +198,13 @@ private async System.Threading.Tasks.Task MenuItemCallbackAsync(object sender, E
196198
try
197199
{
198200
var sarifResults = await CodeQLService.Instance.RunCodeQLQueryAsync(CodeQLService.Instance.SelectedQuery.Trim());
199-
var sarifViewer = new SarifViewerInterop(Package.GetGlobalService(typeof(SVsShell)) as IVsShell);
200-
if (false && sarifViewer.IsSariferExtensionInstalled)
201+
var VsShell = Package.GetGlobalService(typeof(SVsShell)) as IVsShell;
202+
203+
SarifViewerInterop sarifViewer = new SarifViewerInterop(Package.GetGlobalService(typeof(SVsShell)) as IVsShell);
204+
Guid extensionGuid = SarifViewerInterop.ViewerExtensionGuid;
205+
206+
int status = VsShell.IsPackageInstalled(ref extensionGuid, out int installed);
207+
if (installed == 1)
201208
{
202209
if (!sarifViewer.IsViewerExtensionLoaded)
203210
{
@@ -211,6 +218,7 @@ private async System.Threading.Tasks.Task MenuItemCallbackAsync(object sender, E
211218
//if (CodeQLGeneralOptions.Instance.AutomaticallyOpenResults) { }
212219
Microsoft.VisualStudio.Shell.VsShellUtilities.OpenDocument(this.ServiceProvider, sarifResults);
213220
}
221+
214222
}
215223
catch (Exception ex)
216224
{

tools/extensions/CodeQL.VisualStudio/CodeQL.VisualStudio/OutputWindowTracerListener.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ public override void Write(string message)
2727
{
2828
if (this.EnsurePane())
2929
{
30-
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
31-
{
32-
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
33-
this.pane.OutputStringThreadSafe(message);
34-
}).FileAndForget("OutputWindowEvent");
30+
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
31+
{
32+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
33+
this.pane.Activate();
34+
this.pane.OutputStringThreadSafe(message);
35+
}).FileAndForget("OutputWindowEvent");
3536
}
3637
}
3738

tools/extensions/CodeQL.VisualStudio/CodeQL.VisualStudio/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="CodeQL.VisualStudio.Extension.34DD7857-F5F1-4960-B60F-4E9285157836" Version="1.0.0.0" Language="en-US" Publisher="Jacob Ronstadt" />
4+
<Identity Id="CodeQL.VisualStudio.Extension.34DD7857-F5F1-4960-B60F-4E9285157836" Version="0.0.0.1" Language="en-US" Publisher="Microsoft" />
55
<DisplayName>CodeQL Visual Studio Extension</DisplayName>
66
<Description xml:space="preserve">CodeQL Visual Studio Extension</Description>
77
<License>License.txt</License>

0 commit comments

Comments
 (0)