/// <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.");
        }
        /// <summary>
        /// Adds a single XML node for a feature
        /// </summary>
        private void AddFeature(XElement xDocRoot,
                                string featureId,
                                Type type,
                                string featureType,
                                string version,
                                string name,
                                string description,
                                string lang,
                                List <KeyValuePair <Type, Object> > cache,
                                XElement details
                                )
        {
            if (string.IsNullOrEmpty(lang))
            {
                lang = this.GetLanguage(type);
            }
            if (string.IsNullOrEmpty(name) || name == "Unknown")
            {
                name = RsDocExportFeatures.SplitCamelCase(type.Name);
            }

            var featureNode = (from xml2 in xDocRoot.Descendants("Feature")
                               let xElement = xml2.Attribute("Id")
                                              where xElement != null && xElement.Value == featureId
                                              select xml2).FirstOrDefault();

            XElement   eamplesNode = null;
            XAttribute langAttr    = null;

            if (featureNode == null)
            {
                langAttr    = new XAttribute("Language", lang);
                eamplesNode = new XElement("Examples");
                if (featureType != "Inspection")
                {
                    this.FindTestsByType(eamplesNode, type, cache);
                }

                featureNode = new XElement("Feature",
                                           new XAttribute("Type", featureType),
                                           new XAttribute("Id", featureId),
                                           langAttr,
                                           new XAttribute("SinceVersion", version),
                                           new XElement("Title", name),
                                           new XElement("Description", description),
                                           eamplesNode,
                                           details
                                           );
                xDocRoot.Add(featureNode);
            }
            else
            {
                eamplesNode = featureNode.Element("Examples");
                langAttr    = featureNode.Attribute("Language");

                if (!langAttr.Value.Contains(this.GetLanguage(type)) && this.GetLanguage(type) != "all")
                {
                    langAttr.Value = langAttr.Value + "," + this.GetLanguage(type);
                }
                this.FindTestsByType(eamplesNode, type, cache);

                var existingDesc = featureNode.Element("Description");
                if (description.Length > existingDesc.Value.Length)
                {
                    existingDesc.Value = description;
                }
            }

            if (eamplesNode != null)
            {
                foreach (var example in eamplesNode.Elements())
                {
                    if (example.Attribute("Code") == null)
                    {
                        continue;
                    }
                    if (example.Attribute("Code").Value.Contains("+"))
                    {
                        continue;
                    }
                    if (langAttr.Value == "all")
                    {
                        langAttr.Value = example.Attribute("Code").Value;
                    }
                    else
                    {
                        if (!langAttr.Value.Contains(example.Attribute("Code").Value))
                        {
                            langAttr.Value = langAttr.Value + "," + example.Attribute("Code").Value;
                        }
                    }
                }
            }
        }