Esempio n. 1
0
        void Analyse(IDnlibDef def)
        {
            _parsed[def] = def is AssemblyDef ? new OptionList(_projSettings) : new OptionList(_parsed.Values.First());

            //Inherit from containing type if needed...
            if (def is IMemberDef mem && mem.DeclaringType != null && _parsed[mem.DeclaringType].ApplyToMembers)
            {
                _parsed[def].Inherit(_parsed[mem.DeclaringType]);
            }

            foreach (var attribute in GetObfuscationAttributes(def))
            {
                if (attribute.Exclude())
                {
                    _parsed[def] = new OptionList()
                    {
                        Exclude        = true,
                        ApplyToMembers = attribute.ApplyToMembers()
                    };
                    return;
                }

                try
                {
                    //TODO: Maybe change the syntax to something LISP-like... easier to parse...
                    _parsed[def].Inherit(_scope.Resolve <IAttributeParser>().ParseAttribute(attribute));
                }
                catch (ObfuscationAttributeParserException ex)
                {
                    _logger.Warning($"Ignoring settings for {def}:\n{ex}");
                }
            }
        }
Esempio n. 2
0
 internal void Inherit(OptionList other)
 {
     Exclude        = other.Exclude;
     ApplyToMembers = other.ApplyToMembers;
     foreach (var option in other)
     {
         var obj = this.SingleOrDefault(o => o.Name == option.Name);
         if (obj != null)
         {
             var index = IndexOf(obj);
             this[index].Apply = option.Apply;
             for (var i = 0; i < option.Parameters.Count; i++)
             {
                 var pair = option.Parameters.ElementAt(i);
                 this[index].Parameters[pair.Key] = pair.Value;
             }
         }
         else
         {
             Add((Option)option.Clone());
         }
     }
 }