Skip to content

Commit

Permalink
Fixed #156
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletGiraffe committed Sep 18, 2017
1 parent d591f12 commit a9452c7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions CPPCheckPlugin/CPPCheckPluginPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ private static dynamic activeProject()

foreach (dynamic o in activeProjects)
{
dynamic project = o.Object;
if (!isVisualCppProject(project))
if (!isVisualCppProject(o))
{
return null;
}
return project;
return o.Object;
}

return null;
Expand Down Expand Up @@ -289,8 +288,8 @@ private void documentSaved(Document document)
}
try
{
dynamic project = document.ProjectItem.ContainingProject.Object;
if (!isVisualCppProject(project))
var kind = document.ProjectItem.ContainingProject.Kind;
if (!isVisualCppProject(document.ProjectItem.ContainingProject.Kind))
{
return;
}
Expand All @@ -304,6 +303,7 @@ private void documentSaved(Document document)
return;
}

dynamic project = document.ProjectItem.ContainingProject.Object;
SourceFile sourceForAnalysis = createSourceFile(document.FullName, currentConfig, project);
if (sourceForAnalysis == null)
return;
Expand Down Expand Up @@ -428,7 +428,7 @@ private List<ConfiguredFiles> getActiveSelections()
project = selItem.Project;
}

if (project == null || !isVisualCppProject(project.Object))
if (project == null || !isVisualCppProject(project.Kind))
{
continue;
}
Expand Down Expand Up @@ -524,13 +524,14 @@ private void checkSelections()

private List<SourceFile> getProjectFiles(Project p, Configuration currentConfig)
{
dynamic project = p.Object;
if (!isVisualCppProject(project))
if (!isVisualCppProject(p.Kind))
{
System.Windows.MessageBox.Show("Only C++ projects can be checked.");
return null;
}

List<SourceFile> files = new List<SourceFile>();
dynamic project = p.Object;
dynamic projectFiles = project.Files;
foreach (dynamic file in projectFiles)
{
Expand Down Expand Up @@ -641,7 +642,8 @@ private void runAnalysis(List<ConfiguredFiles> configuredFiles, OutputWindowPane

private static SourceFile createSourceFile(string filePath, Configuration targetConfig, dynamic project)
{
Debug.Assert(isVisualCppProject((object)project));
// TODO:
//Debug.Assert(isVisualCppProject((object)project));
try
{
var configurationName = targetConfig.ConfigurationName;
Expand Down Expand Up @@ -680,9 +682,9 @@ private static SourceFile createSourceFile(string filePath, Configuration target
}
}

private static bool isVisualCppProject(object project)
private static bool isVisualCppProject(string kind)
{
return implementsInterface(project, "Microsoft.VisualStudio.VCProjectEngine.VCProject");
return kind.Equals("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}");
}

private static bool implementsInterface(object objectToCheck, String interfaceName)
Expand Down

0 comments on commit a9452c7

Please sign in to comment.