Exemplo n.º 1
0
        public bool ShouldSkip(FieldKey field, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            // skip runtime methods
            if ((field.Field.IsRuntimeSpecialName && field.Field.Name == "value__")) {
                message = "special name";
                return true;
            }

            var attribute = field.Field.MarkedToRename ();
            if (attribute != null) {
                message = "attribute";
                return !attribute.Value;
            }

            var parent = field.DeclaringType.MarkedToRename ();
            if (parent != null) {
                message = "type attribute";
                return !parent.Value;
            }

            if (markedOnly) {
                message = "MarkedOnly option in configuration";
                return true;
            }

            if (ShouldForce (field.TypeKey, TypeAffectFlags.AffectField, map)) {
                message = "type rule in configuration";
                return false;
            }

            if (forceFields.IsMatch (field, map)) {
                message = "field rule in configuration";
                return false;
            }

            if (ShouldSkip (field.TypeKey, TypeAffectFlags.AffectField, map)) {
                message = "type rule in configuration";
                return true;
            }

            if (skipFields.IsMatch (field, map)) {
                message = "field rule in configuration";
                return true;
            }

            if (skipEnums) {
                message = "enum rule in configuration";
                return true;
            }

            if (field.DeclaringType.IsTypePublic () && (field.Field.IsPublic || field.Field.IsFamily)) {
                message = "KeepPublicApi option in configuration";
                return keepPublicApi;
            }

            message = "HidePrivateApi option in configuration";
            return !hidePrivateApi;
        }
Exemplo n.º 2
0
        private void DumpField( TextWriter writer, FieldKey key, ObfuscatedThing info )
        {
            if ( info.Status == ObfuscationStatus.Renamed )
                writer.WriteLine( "\t{0} {1} -> {2}", key.Type, info.Name, info.StatusText );
            else
            {
                Debug.Assert( info.Status == ObfuscationStatus.Skipped,
                    "Status is expected to be either Renamed or Skipped." );

                writer.WriteLine( "\t{0} {1} skipped:  {2}", key.Type, info.Name, info.StatusText );
            }
        }
Exemplo n.º 3
0
 private void DumpField( XmlWriter writer, FieldKey key, ObfuscatedThing info )
 {
     if (info.Status == ObfuscationStatus.Renamed)
     {
         writer.WriteStartElement("renamedField");
         writer.WriteAttributeString("oldName", info.Name);
         writer.WriteAttributeString("newName", info.StatusText);
         writer.WriteEndElement();
         writer.WriteString("\r\n");
     }
     else
     {
         writer.WriteStartElement("skippedField");
         writer.WriteAttributeString("name", info.Name);
         writer.WriteAttributeString("reason", info.StatusText);
         writer.WriteEndElement();
         writer.WriteString("\r\n");
     }
 }
Exemplo n.º 4
0
		public ObfuscatedThing GetField(FieldKey key)
		{
			ObfuscatedClass c = GetClass(key.TypeKey);

			ObfuscatedThing t;
			if (!c.Fields.TryGetValue(key, out t))
			{
				t = new ObfuscatedThing(key.ToString());
				c.Fields[key] = t;
			}

			return t;
		}
Exemplo n.º 5
0
		public void UpdateField(FieldKey key, ObfuscationStatus status, string text)
		{
			ObfuscatedThing f = GetField(key);

			f.Update(status, text);
		}
Exemplo n.º 6
0
		public bool ShouldSkip(FieldKey field, InheritMap map)
		{
			if (ShouldSkip(field.TypeKey, TypeSkipFlags.SkipField, map))
				return true;

			return skipFields.IsMatch(field, map);
		}
Exemplo n.º 7
0
        public bool ShouldSkip(FieldKey field, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            // skip runtime methods
            if ((field.Field.IsRuntimeSpecialName && field.Field.Name == "value__"))
            {
                message = "special name";
                return(true);
            }

            var attribute = field.Field.MarkedToRename();

            if (attribute != null)
            {
                message = "attribute";
                return(!attribute.Value);
            }

            var parent = field.DeclaringType.MarkedToRename();

            if (parent != null)
            {
                message = "type attribute";
                return(!parent.Value);
            }

            if (markedOnly)
            {
                message = "MarkedOnly option in configuration";
                return(true);
            }

            if (ShouldForce(field.TypeKey, TypeAffectFlags.AffectField, map))
            {
                message = "type rule in configuration";
                return(false);
            }

            if (forceFields.IsMatch(field, map))
            {
                message = "field rule in configuration";
                return(false);
            }

            if (ShouldSkip(field.TypeKey, TypeAffectFlags.AffectField, map))
            {
                message = "type rule in configuration";
                return(true);
            }

            if (skipFields.IsMatch(field, map))
            {
                message = "field rule in configuration";
                return(true);
            }

            if (field.DeclaringType.IsTypePublic() && (field.Field.IsPublic || field.Field.IsFamily))
            {
                message = "KeepPublicApi option in configuration";
                return(keepPublicApi);
            }

            message = "HidePrivateApi option in configuration";
            return(!hidePrivateApi);
        }
Exemplo n.º 8
0
 private void DumpField(int tabs, FieldKey key, ObfuscatedThing field, bool isLast)
 {
     WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{field.StatusText}\"{(isLast ? "" : ",")}");
 }
Exemplo n.º 9
0
        public void UpdateField(FieldKey key, ObfuscationStatus status, string text)
        {
            ObfuscatedThing f = GetField(key);

            f.Update(status, text);
        }
Exemplo n.º 10
0
        internal bool ShouldSkip(FieldKey field)
        {
            if (ShouldSkip(field.TypeKey, TypeSkipFlags.SkipField))
                return true;

            return skipFields.IsMatch( field );
        }