Пример #1
0
        /// <summary>
        /// Loads files specified in file lists.
        /// </summary>
        /// <param name="documentRoot">
        /// The root node of the settings document.
        /// </param>
        /// <param name="settings">
        /// Stores the settings.
        /// </param>
        private static void LoadFileLists(XmlNode documentRoot, Settings settings)
        {
            Param.AssertNotNull(documentRoot, "documentRoot");
            Param.AssertNotNull(settings, "settings");

            XmlNodeList fileListNodes = documentRoot.SelectNodes("SourceFileList");

            foreach (XmlNode fileListNode in fileListNodes)
            {
                XmlNodeList fileNodes = fileListNode.SelectNodes("SourceFile");
                if (fileNodes.Count > 0)
                {
                    Settings settingsForFileList = new Settings(settings.Core);

                    XmlNode settingsNode = fileListNode.SelectSingleNode("Settings");
                    if (settingsNode != null)
                    {
                        V104Settings.Load(settingsNode, settingsForFileList);
                    }

                    SourceFileListSettings sourceFileListSettings = new SourceFileListSettings(settingsForFileList);

                    foreach (XmlNode fileNode in fileNodes)
                    {
                        if (!string.IsNullOrEmpty(fileNode.InnerText))
                        {
                            sourceFileListSettings.AddFile(fileNode.InnerText);
                        }
                    }

                    settings.AddSourceFileList(sourceFileListSettings);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Loads the settings from the document.
        /// </summary>
        private void LoadSettingsDocument()
        {
            // Reinitialize the settings collections.
            this.globalSettings.Clear();
            this.parserSettings.Clear();
            this.analyzerSettings.Clear();

            if (this.contents != null)
            {
                // Check the version number of the file.
                XmlAttribute versionAttribute = this.contents.DocumentElement.Attributes["Version"];
                string       version          = versionAttribute == null ? string.Empty : versionAttribute.Value;
                if (string.Equals(version, "105", StringComparison.Ordinal))
                {
                    V105Settings.Load(this.contents, this);
                }
                else if (string.Equals(version, "4.3", StringComparison.Ordinal))
                {
                    V104Settings.Load(this.contents, this);
                }
                else if (string.Equals(version, "4.2", StringComparison.Ordinal))
                {
                    V103Settings.Load(this.contents, this);
                }
                else if (string.Equals(version, "4.1", StringComparison.Ordinal))
                {
                    V102Settings.Load(this.contents, this);
                }
                else
                {
                    V101Settings.Load(this.contents, this);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Loads the settings from the document.
        /// </summary>
        /// <param name="document">
        /// The settings document.
        /// </param>
        /// <param name="settings">
        /// Stores the settings.
        /// </param>
        public static void Load(XmlDocument document, Settings settings)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(settings, "settings");

            // Move the StatementMustNotUseUnnecessaryParenthesis rule from the ReadabilityRules analyzer to the MaintainabilityRules analyzer
            // if it exists.
            MoveRuleToNewAnalyzer(
                document,
                "Microsoft.SourceAnalysis.CSharp.ReadabilityRules",
                "Microsoft.SourceAnalysis.CSharp.MaintainabilityRules",
                "StatementMustNotUseUnnecessaryParenthesis");

            // If the PublicAndProtectedOnly property exists on the DocumentationRules analyzer, rename it to IgnorePrivates.
            V102Settings.ChangeAnalyzerSettingName(document, "Microsoft.SourceAnalysis.CSharp.DocumentationRules", "PublicAndProtectedOnly", "IgnorePrivates");

            // Forward this call to the V4.3 rule class for parsing.
            V104Settings.Load(document, settings);
        }