@@ -83,6 +83,10 @@ private void documentSaved(Document document)
8383 try
8484 {
8585 dynamic project = document . ProjectItem . ContainingProject . Object ;
86+ if ( ! isVisualCppProject ( project ) )
87+ {
88+ return ;
89+ }
8690 var currentConfig = document . ProjectItem . ConfigurationManager . ActiveConfiguration ;
8791 SourceFile sourceForAnalysis = createSourceFile ( document . FullName , currentConfig , project ) ;
8892 if ( sourceForAnalysis == null )
@@ -115,9 +119,7 @@ private void checkCurrentProject()
115119 foreach ( dynamic o in activeProjects )
116120 {
117121 dynamic project = o . Object ;
118- Type projectObjectType = project . GetType ( ) ;
119- var projectInterface = projectObjectType . GetInterface ( "Microsoft.VisualStudio.VCProjectEngine.VCProject" ) ;
120- if ( projectInterface == null )
122+ if ( ! isVisualCppProject ( project ) )
121123 {
122124 System . Windows . MessageBox . Show ( "Only C++ projects can be checked." ) ;
123125 return ;
@@ -205,6 +207,13 @@ SourceFile createSourceFile(string filePath, Configuration targetConfig, dynamic
205207 }
206208 }
207209
210+ private static bool isVisualCppProject ( object project )
211+ {
212+ Type projectObjectType = project . GetType ( ) ;
213+ var projectInterface = projectObjectType . GetInterface ( "Microsoft.VisualStudio.VCProjectEngine.VCProject" ) ;
214+ return projectInterface != null ;
215+ }
216+
208217 private DTE _dte = null ;
209218 private DocumentEvents _eventsHandlers = null ;
210219 private List < ICodeAnalyzer > _analyzers = new List < ICodeAnalyzer > ( ) ;
0 commit comments