Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 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");

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

            // Add the global settings if there are any.
            XmlNode globalSettingsNode = document.DocumentElement["GlobalSettings"];

            if (globalSettingsNode != null)
            {
                LoadPropertyCollection(globalSettingsNode, settings.GlobalSettings, settings.Core.PropertyDescriptors, null);
            }

            // Load the parser settings.
            LoadParserSettings(document, settings);

            // Load the analyzers under this parser.
            LoadAnalyzerSettings(document, settings);
        }