/// <summary> /// Export all features for documentation /// </summary> private void ExportFeaturesForDocumentation() { MessageBox.ShowInfo("latest"); var brwsr = new FolderBrowserDialog() { Description = "Choose where to save the ResharperFeatures.xml file." }; if (brwsr.ShowDialog() == DialogResult.Cancel) { return; } string saveDirectoryPath = brwsr.SelectedPath; string fileName = Path.Combine(saveDirectoryPath, "ResharperFeatures.xml"); var xDoc = new XDocument(); var xDocRoot = new XElement("Features"); // var productVersion = new ReSharperApplicationDescriptor().ProductVersion; // version = String.Format("{0}.{1}", productVersion.Major, productVersion.Minor); this.version = "9.0"; this.myTestAssemblies = new List <Assembly>(); foreach (var testAssemblyName in this.myTestAssemblyNames) { var testAssembly = Assembly.Load(testAssemblyName); this.myTestAssemblies.Add(testAssembly); } var cache = this.GetTestsForFeatures(); // Context actions int cAnumber = 0; // var contextActionTable = Shell.Instance.GetComponent<ContextActionTable>(); // foreach (var ca in contextActionTable.AllActions) // { // AddFeature(xDocRoot, ca.MergeKey.Split('.').Last(), ca.Type, // "ContextAction", version, ca.Name, ca.Description, String.Empty, cache, null); // cAnumber++; // } // Quick fixes and Inspections int qFnumber = 0; int insTypeNumber = 0; var quickFixTable = Shell.Instance.GetComponent <QuickFixTable>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { Type[] types = null; try { types = assembly.GetTypes(); } catch (Exception e) { MessageBox.ShowError("Cannot load assembly!!!!" + e.ToString()); continue; } if (types == null) { continue; } foreach (var type in types) { string name = "Unknown"; string description = "Unknown"; string lang = String.Empty; var attrs = Attribute.GetCustomAttributes(type); // Quick fixes if (typeof(IQuickFix).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { // foreach (var attr in attrs) // { // if (attr is FeatureDescAttribute) // { // var a = (FeatureDescAttribute)attr; // name = a.Title; // description = a.Description; // } // } this.AddFeature(xDocRoot, type.Name, type, "QuickFix", this.version, name, description, lang, cache, null); qFnumber++; } // Inspections if (typeof(IHighlighting).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { string id = string.Empty; string severity = string.Empty; string group = string.Empty; string solutionWide = string.Empty; string allQuickFixes = string.Empty; string configurable = string.Empty; string compoundName = string.Empty; /// TODO: Make GetHighlightingQuickFixesInfo public // var quickFixes = quickFixTable.GetHighlightingQuickFixesInfo(type); // foreach (var quickFix in quickFixes) // allQuickFixes += quickFix.QuickFixType.Name + ","; if (!string.IsNullOrEmpty(allQuickFixes)) { allQuickFixes = allQuickFixes.TrimEnd(','); } foreach (var attr in attrs) { if (attr is ConfigurableSeverityHighlightingAttribute) { var a = (ConfigurableSeverityHighlightingAttribute)attr; id = a.ConfigurableSeverityId; var inpectionInstance = HighlightingSettingsManager.Instance.GetSeverityItem(id); lang = this.GetLangsForInspection(id); if (inpectionInstance != null) { name = inpectionInstance.FullTitle; description = inpectionInstance.HTMLDescriptionBody; severity = inpectionInstance.DefaultSeverity.ToString(); solutionWide = inpectionInstance.SolutionAnalysisRequired ? "yes" : "no"; group = inpectionInstance.GroupId; compoundName = inpectionInstance.CompoundItemName; configurable = "yes"; break; } } if (attr is StaticSeverityHighlightingAttribute) { id = type.Name; var a = (StaticSeverityHighlightingAttribute)attr; name = a.ToolTipFormatString; group = a.GroupId; severity = a.Severity.ToString(); solutionWide = "no"; configurable = "no"; } } if (name != "Unknown") { var details = new XElement("Details", new XAttribute("DefaultSeverity", severity), new XAttribute("Group", group), new XAttribute("SolutionWide", solutionWide), new XAttribute("Configurable", configurable), new XAttribute("CompoundName", compoundName ?? ""), new XAttribute("QuickFixes", allQuickFixes) ); if (string.IsNullOrEmpty(name) && description == "Unknown") { name = RsDocExportFeatures.SplitCamelCase(type.Name); } if (string.IsNullOrEmpty(name)) { name = description; } this.AddFeature(xDocRoot, id, type, "Inspection", this.version, name, description, lang, cache, details); insTypeNumber++; } } } } xDocRoot.Add(new XAttribute("TotalContextActions", cAnumber), new XAttribute("TotalQuickFixes", qFnumber), new XAttribute("TotalInspections", insTypeNumber)); foreach (var ins in HighlightingSettingsManager.Instance.SeverityConfigurations) { var inspection = (from nodes in xDocRoot.Elements() let xAttribute = nodes.Attribute("Id") where xAttribute != null && xAttribute.Value == ins.Id select nodes).FirstOrDefault(); if (inspection == null) { var details = new XElement("Details", new XAttribute("DefaultSeverity", ins.DefaultSeverity), new XAttribute("Group", ins.GroupId), new XAttribute("SolutionWide", ins.SolutionAnalysisRequired ? "yes" : "no"), new XAttribute("Configurable", "yes"), new XAttribute("CompoundName", ins.CompoundItemName ?? ""), new XAttribute("QuickFixes", "") ); this.AddFeature(xDocRoot, ins.Id, ins.GetType(), "Inspection", this.version, ins.FullTitle, ins.HTMLDescriptionBody, this.GetLangsForInspection(ins.Id), null, details); } insTypeNumber++; } xDoc.Add(xDocRoot); this.SynchronizeWithStaticDesciription(xDoc); xDoc.Save(fileName); MessageBox.ShowInfo("ReSharper features exported successfully."); }
private void SynchronizeWithStaticDesciription(XDocument xDoc) { var staticDescriptionXml = new XDocument(); var file = Assembly.GetExecutingAssembly().GetPath().Directory.Directory.Combine("lib/FeatureDescriptionStitic.xml"); if (!file.ExistsFile) { staticDescriptionXml.Add(new XElement("Features")); foreach (var featureNode in xDoc.Root.Elements()) { staticDescriptionXml.Root.Add(new XElement("Feature", new XAttribute("Id", featureNode.Attribute("Id").Value), new XAttribute("SinceVersion", featureNode.Attribute("SinceVersion").Value))); } } else { try { staticDescriptionXml = XDocument.Load(file.FullPath); } catch (XmlException exception) { MessageBox.ShowInfo("FeatureDescriptionStitic.xml is corrupted... /n" + exception); } } foreach (var featureNode in xDoc.Root.Elements()) { var staticFeatureNode = (from nodes in staticDescriptionXml.Root.Elements() where nodes.Attribute("Id").Value == featureNode.Attribute("Id").Value select nodes).FirstOrDefault(); if (staticFeatureNode == null) { staticDescriptionXml.Root.Add(new XElement("Feature", new XAttribute("Id", featureNode.Attribute("Id").Value), new XAttribute("SinceVersion", featureNode.Attribute("SinceVersion").Value))); } else { foreach (var childElement in staticFeatureNode.Elements()) { if (featureNode.Element(childElement.Name) != null) { featureNode.Element(childElement.Name).Remove(); } featureNode.Add(childElement); } foreach (var attribute in staticFeatureNode.Attributes()) { if (featureNode.Attribute(attribute.Name) != null) { featureNode.Attribute(attribute.Name).Remove(); } featureNode.Add(attribute); } } } foreach (var staticFeature in staticDescriptionXml.Root.Elements()) { var dynamicFeatureNode = (from nodes in xDoc.Root.Elements() where nodes.Attribute("Id").Value == staticFeature.Attribute("Id").Value select nodes).FirstOrDefault(); if (dynamicFeatureNode == null && staticFeature.Attribute("DeprecatedSince") == null) { staticFeature.Add(new XAttribute("DeprecatedSince", this.version)); } } staticDescriptionXml.Save(file.FullPath); }