Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Commit 46e9af2

Browse files
author
VioletGiraffe
committed
2 parents 29dc254 + f56e7b0 commit 46e9af2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

CPPCheckPlugin/CPPCheckPluginPackage.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)