Exemplo n.º 1
0
        /// <summary>
        /// Sets the AnalyzeDesignerFiles property on the C# parser.
        /// </summary>
        /// <param name="settings">The settings collection.</param>
        /// <param name="nodeText">The text of the setting from the settings file.</param>
        private static void LoadAnalyzeDesignerFilesSetting(Settings settings, string nodeText)
        {
            Param.AssertNotNull(settings, "settings");
            Param.AssertValidString(nodeText, "nodeText");

            SourceParser parser = settings.Core.GetParser("StyleCop.CSharp.CsParser");

            if (parser != null)
            {
                PropertyDescriptor <bool> propertyDescriptor = parser.PropertyDescriptors["AnalyzeDesignerFiles"] as PropertyDescriptor <bool>;
                if (propertyDescriptor != null)
                {
                    settings.SetAddInSettingInternal(parser, new BooleanProperty(propertyDescriptor, nodeText != "0"));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the given property on the given parser.
        /// </summary>
        /// <param name="settings">The settings collection.</param>
        /// <param name="analyzerId">The ID of the analyzer.</param>
        /// <param name="propertyName">The name of the property to set.</param>
        /// <param name="nodeText">The text of the setting from the settings file.</param>
        private static void LoadAnalyzerSetting(Settings settings, string analyzerId, string propertyName, string nodeText)
        {
            Param.AssertNotNull(settings, "settings");
            Param.AssertValidString(analyzerId, "analyzerId");
            Param.AssertValidString(propertyName, "propertyName");
            Param.AssertValidString(nodeText, "nodeText");

            SourceAnalyzer analyzer = settings.Core.GetAnalyzer(analyzerId);

            if (analyzer != null)
            {
                PropertyDescriptor <bool> propertyDescriptor = analyzer.PropertyDescriptors[propertyName] as PropertyDescriptor <bool>;
                if (propertyDescriptor != null)
                {
                    settings.SetAddInSettingInternal(analyzer, new BooleanProperty(propertyDescriptor, nodeText != "0"));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the valid prefixes from the given node..
        /// </summary>
        /// <param name="validPrefixesNode">The node containing the prefixes.</param>
        /// <param name="settings">The settings collection.</param>
        private static void LoadValidPrefixes(XmlNode validPrefixesNode, Settings settings)
        {
            Param.AssertNotNull(validPrefixesNode, "validPrefixesNode");
            Param.AssertNotNull(settings, "settings");

            string[] prefixes = validPrefixesNode.InnerText.Split(',');

            // Get the analyzer.
            SourceAnalyzer analyzer = settings.Core.GetAnalyzer("StyleCop.CSharp.NamingRules");

            if (analyzer != null)
            {
                // Get the property descriptor.
                CollectionPropertyDescriptor propertyDescriptor = analyzer.PropertyDescriptors["Hungarian"] as CollectionPropertyDescriptor;
                if (propertyDescriptor != null)
                {
                    settings.SetAddInSettingInternal(analyzer, new CollectionProperty(propertyDescriptor, prefixes));
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the valid prefixes from the given node..
        /// </summary>
        /// <param name="validPrefixesNode">
        /// The node containing the prefixes.
        /// </param>
        /// <param name="settings">
        /// The settings collection.
        /// </param>
        private static void LoadValidPrefixes(XmlNode validPrefixesNode, Settings settings)
        {
            Param.AssertNotNull(validPrefixesNode, "validPrefixesNode");
            Param.AssertNotNull(settings, "settings");

            string[] prefixes = validPrefixesNode.InnerText.Split(',');

            // Get the analyzer.
            SourceAnalyzer analyzer = settings.Core.GetAnalyzer("StyleCop.CSharp.NamingRules");
            if (analyzer != null)
            {
                // Get the property descriptor.
                CollectionPropertyDescriptor propertyDescriptor = analyzer.PropertyDescriptors["Hungarian"] as CollectionPropertyDescriptor;
                if (propertyDescriptor != null)
                {
                    settings.SetAddInSettingInternal(analyzer, new CollectionProperty(propertyDescriptor, prefixes));
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the given property on the given parser.
        /// </summary>
        /// <param name="settings">
        /// The settings collection.
        /// </param>
        /// <param name="analyzerId">
        /// The ID of the analyzer.
        /// </param>
        /// <param name="propertyName">
        /// The name of the property to set.
        /// </param>
        /// <param name="nodeText">
        /// The text of the setting from the settings file.
        /// </param>
        private static void LoadAnalyzerSetting(Settings settings, string analyzerId, string propertyName, string nodeText)
        {
            Param.AssertNotNull(settings, "settings");
            Param.AssertValidString(analyzerId, "analyzerId");
            Param.AssertValidString(propertyName, "propertyName");
            Param.AssertValidString(nodeText, "nodeText");

            SourceAnalyzer analyzer = settings.Core.GetAnalyzer(analyzerId);
            if (analyzer != null)
            {
                PropertyDescriptor<bool> propertyDescriptor = analyzer.PropertyDescriptors[propertyName] as PropertyDescriptor<bool>;
                if (propertyDescriptor != null)
                {
                    settings.SetAddInSettingInternal(analyzer, new BooleanProperty(propertyDescriptor, nodeText != "0"));
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the AnalyzeDesignerFiles property on the C# parser.
        /// </summary>
        /// <param name="settings">
        /// The settings collection.
        /// </param>
        /// <param name="nodeText">
        /// The text of the setting from the settings file.
        /// </param>
        private static void LoadAnalyzeDesignerFilesSetting(Settings settings, string nodeText)
        {
            Param.AssertNotNull(settings, "settings");
            Param.AssertValidString(nodeText, "nodeText");

            SourceParser parser = settings.Core.GetParser("StyleCop.CSharp.CsParser");
            if (parser != null)
            {
                PropertyDescriptor<bool> propertyDescriptor = parser.PropertyDescriptors["AnalyzeDesignerFiles"] as PropertyDescriptor<bool>;
                if (propertyDescriptor != null)
                {
                    settings.SetAddInSettingInternal(parser, new BooleanProperty(propertyDescriptor, nodeText != "0"));
                }
            }
        }