Beispiel #1
0
        private void AddProjectFile(string guid, string solutionFolder, string relativeProjectFilename)
        {
            string solutionDir             = _solutionFileInfo.DirectoryName;
            string absoluteProjectFilename = ResolvePath(solutionDir, relativeProjectFilename);

            if (absoluteProjectFilename != null)
            {
                FileInfo projectFileInfo = new FileInfo(absoluteProjectFilename);
                if (projectFileInfo.Exists)
                {
                    if (absoluteProjectFilename.EndsWith("vcxproj"))
                    {
                        ProjectFile projectFile = new ProjectFile(solutionFolder, solutionDir, absoluteProjectFilename, _analyzerSettings);
                        _projects[guid] = projectFile;
                    }
                    else
                    {
                        Logger.LogInfo("File ignored " + absoluteProjectFilename);
                    }
                }
                else
                {
                    AnalyzerLogger.LogErrorFileNotFound(absoluteProjectFilename, _solutionFileInfo.FullName);
                }
            }
            else
            {
                AnalyzerLogger.LogErrorPathNotResolved(relativeProjectFilename, _solutionFileInfo.FullName);
            }
        }
Beispiel #2
0
 private void RegisterSourceFile(SourceFile sourceFile)
 {
     if (sourceFile.FileInfo.Exists)
     {
         string name = ExtractSourceFileUniqueName(sourceFile.Name);
         string type = sourceFile.Extension;
         _model.AddElement(name, type, sourceFile.FileInfo.FullName);
     }
     else
     {
         AnalyzerLogger.LogErrorFileNotFound(sourceFile.Name, "source directory");
     }
 }
Beispiel #3
0
 private void AddHeaderFile(ProjectItem projectItem)
 {
     try
     {
         string   projectFolder = _filterFile.GetSourceFileProjectFolder(projectItem.EvaluatedInclude);
         FileInfo fileInfo      = new FileInfo(GetAbsolutePath(_projectFileInfo.DirectoryName, projectItem.EvaluatedInclude));
         if (fileInfo.Exists)
         {
             AddSourceFile(fileInfo, projectFolder);
         }
         else
         {
             AnalyzerLogger.LogErrorFileNotFound(fileInfo.FullName, _projectFileInfo.Name);
         }
     }
     catch (Exception e)
     {
         Logger.LogException($"Add  header file failed project={_projectFileInfo.FullName} file={projectItem.EvaluatedInclude}", e);
     }
 }
Beispiel #4
0
        private void RegisterSourceFile(SolutionFile solutionFile, ProjectFile visualStudioProject, SourceFile sourceFile)
        {
            Logger.LogInfo("Source file registered: " + sourceFile.Name);

            string type = sourceFile.FileType;

            _sourcesFilesById[sourceFile.Id] = sourceFile.SourceFileInfo;

            if (sourceFile.SourceFileInfo.Exists)
            {
                switch (_analyzerSettings.ViewMode)
                {
                case ViewMode.LogicalView:
                {
                    string name = GetLogicalName(solutionFile, visualStudioProject, sourceFile);
                    _model.AddElement(name, type, sourceFile.SourceFileInfo.FullName);
                    break;
                }

                case ViewMode.PhysicalView:
                {
                    string name = GetPhysicalName(sourceFile);
                    _model.AddElement(name, type, sourceFile.SourceFileInfo.FullName);
                    break;
                }

                default:
                    Logger.LogError("Unknown view mode");
                    break;
                }
            }
            else
            {
                AnalyzerLogger.LogErrorFileNotFound(sourceFile.Name, visualStudioProject.ProjectName);
            }
        }