99using Microsoft . VisualStudio . Shell . Interop ;
1010using Microsoft . VisualStudio . Threading ;
1111using System ;
12+ using System . Collections ;
1213using System . Collections . Generic ;
1314using System . ComponentModel . Design ;
1415using System . Diagnostics ;
1516using System . Linq ;
1617using System . Linq . Expressions ;
18+ using System . Reflection . Metadata ;
1719using System . Runtime . InteropServices ;
1820using System . Security . Policy ;
1921using 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 {
0 commit comments