Пример #1
0
        private ImmutableDictionary <string, bool> BuildRuleMapFromOptions()
        {
            var result = new Dictionary <string, bool>();

            var propertyBag = OptionsHelper.BuildDefaultPropertyBag();

            if (!string.IsNullOrEmpty(OptionsFilePath))
            {
                propertyBag.LoadFrom(OptionsFilePath);
            }

            propertyBag = (PropertyBag)propertyBag["CodeFormatterRules.Options"];
            foreach (string key in propertyBag.Keys)
            {
                string[] tokens = key.Split('.');
                Debug.Assert(tokens.Length == 2);
                Debug.Assert(tokens[1].Equals("Enabled"));

                string rule = tokens[0];
                result[rule] = (bool)propertyBag[key];
            }

            _ruleMap = result.ToImmutableDictionary();
            return(_ruleMap);
        }
Пример #2
0
        protected PropertyBag CreatePolicyThatDisablesAllAnalysis()
        {
            PropertyBag propertyBag = OptionsHelper.BuildDefaultPropertyBag();

            foreach (string analyzerName in OptionsHelper.AllAnalyzerNames)
            {
                propertyBag.SetProperty(OptionsHelper.BuildDefaultEnabledProperty(analyzerName), false);
            }
            return(propertyBag);
        }
Пример #3
0
        private static int RunExportOptionsCommand(ExportOptions exportOptions)
        {
            int         result     = FAILED;
            PropertyBag allOptions = OptionsHelper.BuildDefaultPropertyBag();

            allOptions.SaveTo(exportOptions.OutputPath, id: "codeformatter-options");
            Console.WriteLine("Options file saved to: " + Path.GetFullPath(exportOptions.OutputPath));

            result = SUCCEEDED;

            return(result);
        }