private void ProcessProject(ProjectInfo projectInfo) { // TODO change this logic from exclusive to inclusive -- make sure project file type is supported if (projectInfo.RelativePath.StartsWith("http://")) { // TODO attempt to resolve URL to a filesystem address return; } else if (projectInfo.RelativePath.EndsWith(".dbp")) { // TODO don't know what to do with database projects just yet... return; } else if (projectInfo.RelativePath.EndsWith(".vdproj")) { // TODO don't know what to do with installer projects just yet... return; } string projectFilePathAbsolute = Path.Combine(_solutionPath, projectInfo.RelativePath); AddMessage("{0} depends upon:", projectInfo.Name); string projectFileContent = ReadEntireStream(File.OpenRead(projectFilePathAbsolute)); string[] dependencies = ExtractDependenciesFromProject(projectFileContent); foreach (string dependency in dependencies) { AddMessage("- {0}", dependency); DependencyGraph.AddDependency(projectInfo.Name, dependency); } }
/// <summary> /// Merges the specified assembly and its dependencies into this analyser's current dependency graph. Any /// dependencies will also be processed (this method may recurse). /// </summary> public void ProcessAssembly(Assembly assembly) { if (assembly==null) { throw new ArgumentException("Cannot process null assembly"); } if (_knownAssemblies.Contains(assembly)) { // this assembly has already been processed return; } _knownAssemblies.Add(assembly); AddMessage("----------------------------------------------------------------"); AddMessage("Processing assembly: {0}", assembly.FullName); var assemblyName = assembly.FullName.Split(',')[0]; var projectInfo = new ProjectInfo(assembly.CodeBase, assemblyName); var dependencies = assembly.GetReferencedAssemblies(); AddMessage("{0} depends upon:", assemblyName); foreach (var dependantAssemblyName in dependencies) { AddMessage("- {0}", dependantAssemblyName.Name); DependencyGraph.AddDependency(assemblyName, dependantAssemblyName.Name); try { var dependantAssembly = LoadAssemblyFromAssemblyName(dependantAssemblyName); ProcessAssembly(dependantAssembly); } catch (Exception e) { AddMessage("Unable to load assembly: {0}", dependantAssemblyName.FullName); AddMessage("{0}", e.ToString()); } } _projectInfoArrayList.Add(projectInfo); }