public void checkIfSourceCodeReferencesAreValid() { Application.DoEvents(); lbFixSourceCodeFilereferences.Visible = false; lbAssessmentFilesThatNeedSourceCodePathFixing.Visible = false; lbAssessmentFilesThatNeedSourceCodePathFixing.Items.Clear(); foreach (O2AssessmentData_OunceV6 oadO2AssessmentData in lbLoadedAssessmentFiles.Items) { if (oadO2AssessmentData != null) { if (false == SourceCodeFiles.areAllSourceCodeReferencesInAssessmentFileValid(oadO2AssessmentData)) { // first try to fix this file using current Source Code Mappings: SourceCodeFiles.tryToFixSourceCodeReferences(oadO2AssessmentData); // then check again if (false == SourceCodeFiles.areAllSourceCodeReferencesInAssessmentFileValid(oadO2AssessmentData)) { // and if there are still problems add it to the list of assessment files that need source code fixing lbAssessmentFilesThatNeedSourceCodePathFixing.Items.Add(oadO2AssessmentData); } } } } if (lbAssessmentFilesThatNeedSourceCodePathFixing.Items.Count > 0) { lbFixSourceCodeFilereferences.Visible = true; lbAssessmentFilesThatNeedSourceCodePathFixing.Visible = true; } //if (dgvSearchCriteria.Rows.Count == 0) // if there is no query in there (means this is the first time we are running this), so add the default search addSearchCriteria("Vuln_Type", ".", true); btExecuteSearch_Click(null, null); }
/* public void loadAssessmentFile(String sAssessmentFileToLoad) * { * //lbLoadedAssessmentFile.Text = sAssessmentFileToLoad; * //oadO2AssessmentData = new O2AssessmentLoad_OunceV6(); * .loadFile(sAssessmentFileToLoad); * * //Analysis.loadAssessmentFile(sAssessmentFileToLoad, false /*bVerbose* /, true * ///*bResolveReferences* /); * loadFileMappingsIntoListBoxes(); * }*/ private void loadFileMappingsIntoListBoxes() { if (oadO2AssessmentData != null) { List <String> lsUniqueFilesInAssessment = SourceCodeFiles.getListOfUniqueFiles(oadO2AssessmentData); lbFilesFoundOnThisComputer.Items.Clear(); lbFilesNOTFoundOnThisComputer.Items.Clear(); foreach (String sFile in lsUniqueFilesInAssessment) { if (File.Exists(sFile)) { lbFilesFoundOnThisComputer.Items.Add(sFile); } else { lbFilesNOTFoundOnThisComputer.Items.Add(sFile); } } if (lbFilesFoundOnThisComputer.Items.Count > 0) { lbFilesFoundOnThisComputer.SelectedIndex = 0; } btAllDoneCloseModule.Visible = (lbFilesNOTFoundOnThisComputer.Items.Count == 0 && lbFilesFoundOnThisComputer.Items.Count > 0); } }
private void btFixAllFilesWithMapping_Click(object sender, EventArgs e) { try { SourceCodeFiles.fixAllFileReferencesOnAssessmentDataObject(oadO2AssessmentData, rfmResolvedFileMapping); loadAssessmentFile(oadO2AssessmentData); } catch (Exception ex) { DI.log.error("in btFixAllFilesWithMapping_Click:{0}", ex.Message); } }
private void HandleErrorDataReceived(string data) { if (string.IsNullOrEmpty(data)) { return; } try { Match match = ErrorMessageFormat.Match(data); if (!match.Success) { this.AddDiagnostic(DiagnosticSeverity.Info, -1, null, -1, -1, data); return; } string severity = match.Groups["SEVERITY"].Value; string fileName = match.Groups["FILE"].Value; int.TryParse(match.Groups["ERRORCODE"].Value, out int errorCode); int.TryParse(match.Groups["COLUMN"].Value, out int column); int.TryParse(match.Groups["LINE"].Value, out int line); string message = match.Groups["MESSAGE"].Value; string filePath = SourceCodeFiles.FirstOrDefault(f => f.EndsWith(fileName)) ?? fileName; switch (severity) { case "error": case "fatal": this.AddDiagnostic(DiagnosticSeverity.Error, errorCode, filePath, line, column, message); break; case "warning": this.AddDiagnostic(DiagnosticSeverity.Warning, errorCode, filePath, line, column, message); break; case "info": default: this.AddDiagnostic(DiagnosticSeverity.Info, errorCode, filePath, line, column, message); break; } } catch (Exception ex) { this.AddDiagnostic(DiagnosticSeverity.Error, -1, null, -1, -1, ex.ToString().Replace('\r', ' ').Replace('\n', ' ')); } }
public VsTemplate(string templateName) { Name = templateName; templatePath = Path.Combine("VisualStudioTemplates", "Delta Engine", templateName + ".zip"); PathToZip = GetPathToVisualStudioTemplateZip(templateName); var basePath = GetBasePath(PathToZip); AssemblyInfo = Path.Combine(basePath, "Properties", "AssemblyInfo.cs"); Csproj = Path.Combine(basePath, templateName + ".csproj"); foreach (var entry in ZipFile.Read(PathToZip).Entries) { if (entry.FileName.EndsWith(".ico") || entry.FileName.EndsWith(".png")) { Icons.Add(Path.Combine(basePath, entry.FileName)); } if (!entry.FileName.Contains("AssemblyInfo.cs") && entry.FileName.EndsWith(".cs")) { SourceCodeFiles.Add(Path.Combine(basePath, entry.FileName)); } } }