Example #1
0
 public void RefreshConfig()
 {
     lock (RefreshLockObject)
     {
         EnsureInitialized();
         _configLoadResult = RefreshConfigCore();
     }
 }
Example #2
0
        private ConfigLoadResult CombineFileConfigProvidersAndSaveResult()
        {
            _lastInheritanceDepth = InheritanceDepth;
            _lastConfigLoadResult = CombineFileConfigProviders();

            LogTraceMessage(IndentHelper.Indent("Effective config:", 1).Concat(IndentHelper.Indent(_lastConfigLoadResult.ToStrings(), 2)));

            return(_lastConfigLoadResult);
        }
Example #3
0
        protected void EnsureInitialized()
        {
            if (_isInitialized)
            {
                return;
            }

            _isInitialized    = true;
            _configLoadResult = LoadConfigCore();
        }
        public void UpdateMaxIssueCount(int newValue)
        {
            lock (SaveLoadLockObject)
            {
                EnsureInitialized();

                if (_configLoadResult.ConfigState != AnalyzerConfigState.Enabled)
                {
                    throw new InvalidOperationException($"Cannot {nameof(UpdateMaxIssueCount)} in {_configLoadResult.ConfigState} state.");
                }

                _configLoadResult = UpdateMaxIssueCountCore(newValue);
            }
        }
Example #5
0
        private ConfigLoadResult CombineFileConfigProviders()
        {
            var configBuilder = CreateAnalyzerConfigBuilder();

            var anyConfigFound = false;

            foreach (var childConfigProvider in Enumerable.Reverse(_fileConfigProviders))
            {
                var childConfigState = childConfigProvider.ConfigState;

                LogTraceMessage(IndentHelper.Indent($"Combining {childConfigProvider}, state={childConfigState}", 1));

                switch (childConfigState)
                {
                case AnalyzerConfigState.NoConfig:
                    break;

                case AnalyzerConfigState.Disabled:
                    anyConfigFound = true;
                    configBuilder.SetIsEnabled(false);
                    break;

                case AnalyzerConfigState.Enabled:
                    anyConfigFound = true;

                    var childConfigBuilder = childConfigProvider.ConfigBuilder;
                    configBuilder.Combine(childConfigBuilder);
                    LogTraceMessage(IndentHelper.Indent(childConfigBuilder.ToStrings(), 2));
                    break;

                case AnalyzerConfigState.ConfigError:
                    return(ConfigLoadResult.CreateWithError(childConfigProvider.ConfigException));

                default:
                    throw new ArgumentOutOfRangeException(nameof(childConfigState), childConfigState, "Unexpected value.");
                }
            }

            return(anyConfigFound
                ? ConfigLoadResult.CreateWithConfig(configBuilder)
                : ConfigLoadResult.CreateWithNoConfig());
        }
        private ConfigLoadResult LoadConfigFromFile()
        {
            try
            {
                _configFileExists = File.Exists(ConfigFilePath);
                if (!_configFileExists)
                {
                    return(ConfigLoadResult.CreateWithNoConfig());
                }

                _configLastLoadUtc = DateTime.UtcNow;

                var configBuilder = CreateConfigBuilderFromFile(ConfigFilePath)
                                    .SetDefaultInfoImportance(DefaultInfoImportance);

                return(ConfigLoadResult.CreateWithConfig(configBuilder));
            }
            catch (Exception e)
            {
                LogTraceMessage($"BuildConfig exception: {e}");
                return(ConfigLoadResult.CreateWithError(e));
            }
        }
 protected override ConfigLoadResult LoadConfigCore()
 {
     _lastConfigLoadResult = LoadConfigFromFile();
     return(_lastConfigLoadResult);
 }