예제 #1
0
        private static ConfigFilterRule LoadRules(string configFile)
        {
            if (string.IsNullOrEmpty(configFile))
            {
                return(new ConfigFilterRule());
            }
            if (!File.Exists(configFile))
            {
                throw new FileNotFoundException($"Filter Config file {configFile} does not exist!");
            }

            ConfigFilterRule rule = null;

            try
            {
                rule = YamlUtility.Deserialize <ConfigFilterRule>(configFile);
            }
            catch (Exception e)
            {
                throw new InvalidDataException($"Error parsing filter config file {configFile}: {e.Message}");
            }

            if (rule == null)
            {
                throw new InvalidDataException($"Unable to deserialize filter config {configFile}.");
            }
            return(rule);
        }
예제 #2
0
 private static ConfigFilterRule MergeConfigRule(ConfigFilterRule defaultRule, ConfigFilterRule userRule)
 {
     return(new ConfigFilterRule
     {
         // user rule always overwrite default rule
         ApiRules = userRule.ApiRules.Concat(defaultRule.ApiRules).ToList(),
         AttributeRules = userRule.AttributeRules.Concat(defaultRule.AttributeRules).ToList(),
     });
 }
예제 #3
0
        public SymbolVisitorAdapter(YamlModelGenerator generator, SyntaxLanguage language, Compilation compilation, bool preserveRawInlineComments = false, string filterConfigFile = null, IReadOnlyDictionary <Compilation, IEnumerable <IMethodSymbol> > extensionMethods = null)
        {
            _generator                 = generator;
            Language                   = language;
            _currentCompilation        = compilation;
            _currentCompilationRef     = compilation.ToMetadataReference();
            _preserveRawInlineComments = preserveRawInlineComments;
            var configFilterRule = ConfigFilterRule.LoadWithDefaults(filterConfigFile);

            FilterVisitor     = new DefaultFilterVisitor().WithConfig(configFilterRule).WithCache();
            _extensionMethods = extensionMethods != null?extensionMethods.ToDictionary(p => p.Key, p => p.Value.Where(e => FilterVisitor.CanVisitApi(e))) : new Dictionary <Compilation, IEnumerable <IMethodSymbol> >();
        }
예제 #4
0
        public SymbolVisitorAdapter(YamlModelGenerator generator, SyntaxLanguage language, Compilation compilation, ExtractMetadataOptions options)
        {
            _generator                 = generator;
            Language                   = language;
            _currentCompilation        = compilation;
            _currentCompilationRef     = compilation.ToMetadataReference();
            _preserveRawInlineComments = options.PreserveRawInlineComments;
            var configFilterRule = ConfigFilterRule.LoadWithDefaults(options.FilterConfigFile);
            var filterVisitor    = options.DisableDefaultFilter ? (IFilterVisitor) new AllMemberFilterVisitor() : new DefaultFilterVisitor();

            FilterVisitor     = filterVisitor.WithConfig(configFilterRule).WithCache();
            _extensionMethods = options.RoslynExtensionMethods != null?options.RoslynExtensionMethods.ToDictionary(p => p.Key, p => p.Value.Where(e => FilterVisitor.CanVisitApi(e))) : new Dictionary <Compilation, IEnumerable <IMethodSymbol> >();

            _codeSourceBasePath = options.CodeSourceBasePath;
        }
예제 #5
0
 public ConfigFilterVisitor(IFilterVisitor inner, string configFile)
     : base(inner)
 {
     _configFile = configFile;
     _configRule = LoadRules(configFile);
 }
예제 #6
0
 public ConfigFilterVisitor(IFilterVisitor inner, ConfigFilterRule rule)
     : base(inner)
 {
     _configRule = rule;
 }
예제 #7
0
 public ConfigFilterVisitor(IFilterVisitor inner, string configFile)
     : base(inner)
 {
     _configRule = ConfigFilterRule.Load(configFile);
 }
예제 #8
0
 public ConfigFilterVisitor(IFilterVisitor inner, ConfigFilterRule rule)
     : base(inner)
 {
     _configRule = rule;
 }
예제 #9
0
 public ConfigFilterVisitor(IFilterVisitor inner, string configFile)
     : base(inner)
 {
     _configFile = configFile;
     _configRule = LoadRules(configFile);
 }