private void LoadDiagnosticsFromPath(string folderPath, bool syncInServer) { var diagnostics = Directory.GetFiles(folderPath); foreach (var diagnostic in diagnostics) { try { var fileName = Path.GetFileName(diagnostic); if (this.ExtensionDiagnostics.ContainsKey(fileName)) { continue; } var newdata = new VSSonarExtensionDiagnostic(fileName, diagnostic); if (newdata.AvailableChecks.Count > 0) { this.ExtensionDiagnostics.Add(fileName, newdata); if (syncInServer) { this.SyncDiagnosticInServer(newdata); } } } catch (Exception ex) { this.notificationManager.WriteMessage("Failed to load user diagnostics from: " + diagnostic + " : " + ex.Message); } } }
/// <summary> /// Adds the new roslyn pack. /// </summary> /// <param name="dllPath">The DLL path.</param> /// <returns>true if ok</returns> public bool AddNewRoslynPack(string dllPath, bool updateProps) { var name = Path.GetFileName(dllPath); if (!File.Exists(dllPath)) { return(false); } try { var diagnostic = new VSSonarExtensionDiagnostic(name, dllPath); if (this.ExtensionDiagnostics.ContainsKey(name)) { this.notificationManager.ReportMessage(new Message { Id = "RoslynManager", Data = name + " already added to list." }); return(false); } if (diagnostic.AvailableChecks.Count != 0) { this.SyncDiagnosticInServer(diagnostic); this.ExtensionDiagnostics.Add(name, diagnostic); } else { this.notificationManager.ReportMessage(new Message { Id = "RoslynManager", Data = name + " contains 0 diagnostics, will not import. Perhaps its a reference." }); return(false); } } catch (Exception ex) { this.notificationManager.ReportMessage(new Message { Id = "RoslynManager", Data = name + " failed, will skip: " + ex.Message }); this.notificationManager.ReportException(ex); return(false); } return(true); }
/// <summary> /// Synchronizes the diagnostic in server. /// </summary> /// <param name="diagnostic">The diagnostic.</param> private void SyncDiagnosticInServer(VSSonarExtensionDiagnostic diagnostic) { if (diagnostic.AvailableChecks.Count == 0) { return; } foreach (var check in diagnostic.AvailableChecks) { foreach (var diag in check.Diagnostic.SupportedDiagnostics) { foreach (var lang in check.Languages) { var language = GetLanguage(lang); this.CreateRule(language, diag); } } } }
/// <summary> /// Removes the DLL from list. /// </summary> /// <param name="selectedDllDiagnostic">The selected DLL diagnostic.</param> internal void RemoveDllFromList(VSSonarExtensionDiagnostic selectedDllDiagnostic) { this.ExtensionDiagnostics.Remove(selectedDllDiagnostic.Name); }
/// <summary> /// Adds the new roslyn pack. /// </summary> /// <param name="dllPath">The DLL path.</param> /// <returns>true if ok</returns> public bool AddNewRoslynPack(string dllPath, bool updateProps) { var name = Path.GetFileName(dllPath); if (!File.Exists(dllPath)) { return false; } try { var diagnostic = new VSSonarExtensionDiagnostic(name, dllPath); if (this.ExtensionDiagnostics.ContainsKey(name)) { this.notificationManager.ReportMessage(new Message { Id = "RoslynManager", Data = name + " already added to list." }); return false; } if (diagnostic.AvailableChecks.Count != 0) { this.SyncDiagnosticInServer(diagnostic); this.ExtensionDiagnostics.Add(name, diagnostic); } else { this.notificationManager.ReportMessage(new Message { Id = "RoslynManager", Data = name + " contains 0 diagnostics, will not import. Perhaps its a reference." }); return false; } } catch (Exception ex) { this.notificationManager.ReportMessage(new Message { Id = "RoslynManager", Data = name + " failed, will skip: " + ex.Message }); this.notificationManager.ReportException(ex); return false; } return true; }