Exemple #1
0
        public bool Test(PropertyKey prop, InheritMap map)
        {
            // method name matches type regex?
            if (!String.IsNullOrEmpty(type) && !Helper.CompareOptionalRegex(prop.TypeKey.Fullname, type))
            {
                return(false);
            }

            // method visibility matches
            if (MethodTester.CheckMemberVisibility(attrib, typeAttrib, GetPropertyMethodAttributes(prop.Property), prop.DeclaringType))
            {
                return(false);
            }

            // method's name matches
            if (nameRx != null && !nameRx.IsMatch(prop.Name))
            {
                return(false);
            }

            // method's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(prop.Name, name))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public void LoadAssemblies()
        {
            // build reference tree
            foreach (AssemblyInfo info in assemblyList)
            {
                // add self reference...makes things easier later, when
                // we need to go through the member references
                info.ReferencedBy.Add(info);

                // try to get each assembly referenced by this one.  if it's in
                // the map (and therefore in the project), set up the mappings
                foreach (AssemblyNameReference nameRef in info.Definition.MainModule.AssemblyReferences)
                {
                    AssemblyInfo reference;
                    if (assemblyMap.TryGetValue(nameRef.Name, out reference))
                    {
                        info.References.Add(reference);
                        reference.ReferencedBy.Add(info);
                    }
                }
            }

            // make each assembly's list of member refs
            foreach (AssemblyInfo info in assemblyList)
            {
                info.Init();
            }

            // build inheritance map
            inheritMap = new InheritMap(this);
        }
Exemple #3
0
        public bool Test(EventKey evt, InheritMap map)
        {
            // method name matches type regex?
            if (!String.IsNullOrEmpty(type) && !Helper.CompareOptionalRegex(evt.TypeKey.Fullname, type))
            {
                return(false);
            }

            if (MethodTester.CheckMemberVisibility(attrib, typeAttrib, GetEventMethodAttributes(evt.Event), evt.DeclaringType))
            {
                return(false);
            }

            // method's name matches
            if (nameRx != null && !nameRx.IsMatch(evt.Name))
            {
                return(false);
            }

            // method's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(evt.Name, name))
            {
                return(false);
            }

            return(true);
        }
Exemple #4
0
        public bool ShouldSkipStringHiding(MethodKey method, InheritMap map, bool projectHideStrings)
        {
            if (method.DeclaringType.IsResourcesType() &&
                method.Method.ReturnType.FullName == "System.Resources.ResourceManager")
            {
                return(true); // IMPORTANT: avoid hiding resource type name, as it might be renamed later.
            }
            if (ShouldForce(method.TypeKey, TypeAffectFlags.AffectString, map))
            {
                return(false);
            }

            if (forceStringHiding.IsMatch(method, map))
            {
                return(false);
            }

            if (ShouldSkip(method.TypeKey, TypeAffectFlags.AffectString, map))
            {
                return(true);
            }

            if (skipStringHiding.IsMatch(method, map))
            {
                return(true);
            }

            return(!projectHideStrings);
        }
Exemple #5
0
        public bool ShouldSkip(MethodKey method, InheritMap map, bool keepPublicApi, bool hidePrivateApi,
                               bool markedOnly, out string message)
        {
            if (method.Method.IsRuntime)
            {
                message = "runtime method";
                return(true);
            }

            if (method.Method.IsSpecialName)
            {
                switch (method.Method.SemanticsAttributes)
                {
                case MethodSemanticsAttributes.Getter:
                case MethodSemanticsAttributes.Setter:
                    message = "skipping properties";
                    return(!project.Settings.RenameProperties);

                case MethodSemanticsAttributes.AddOn:
                case MethodSemanticsAttributes.RemoveOn:
                    message = "skipping events";
                    return(!project.Settings.RenameEvents);

                default:
                    message = "special name";
                    return(true);
                }
            }

            return(ShouldSkipParams(method, map, keepPublicApi, hidePrivateApi, markedOnly, out message));
        }
Exemple #6
0
        public bool ShouldSkip(EventKey evt, InheritMap map, bool keepPublicApi, bool hidePrivateApi, out string skiprename)
        {
            // skip runtime special events
            if (evt.Event.IsRuntimeSpecialName)
            {
                skiprename = "runtime special name";
                return(true);
            }

            var attribute = evt.Event.MarkedToRename();

            // skip runtime methods
            if (attribute != null)
            {
                skiprename = "attribute";
                return(!attribute.Value);
            }

            var parent = evt.DeclaringType.MarkedToRename();

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

            if (ShouldForce(evt.TypeKey, TypeAffectFlags.AffectEvent, map))
            {
                skiprename = "type rule in configuration";
                return(false);
            }

            if (forceEvents.IsMatch(evt, map))
            {
                skiprename = "event rule in configuration";
                return(false);
            }

            if (ShouldSkip(evt.TypeKey, TypeAffectFlags.AffectEvent, map))
            {
                skiprename = "type rule in configuration";
                return(true);
            }

            if (skipEvents.IsMatch(evt, map))
            {
                skiprename = "event rule in configuration";
                return(true);
            }

            if (evt.DeclaringType.IsTruePublic() && (IsAddPublic(evt.Event) || IsRemovePublic(evt.Event)))
            {
                skiprename = "KeepPublicApi option in configuration";
                return(keepPublicApi);
            }

            skiprename = "HidePrivateApi option in configuration";
            return(!hidePrivateApi);
        }
Exemple #7
0
        public bool ShouldSkipParams(MethodKey method, InheritMap map, bool keepPublicApi, bool hidePrivateApi,
                                     bool markedOnly, out string message)
        {
            var attribute = method.Method.MarkedToRename();

            // skip runtime methods
            if (attribute != null)
            {
                message = "attribute";
                return(!attribute.Value);
            }

            var parent = method.DeclaringType.MarkedToRename();

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

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

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

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

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

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

            if (method.DeclaringType.IsTypePublic() && method.Method.IsPublic())
            {
                message = "KeepPublicApi option in configuration";
                return(keepPublicApi);
            }

            message = "HidePrivateApi option in configuration";
            return(!hidePrivateApi);
        }
Exemple #8
0
        public bool ShouldSkip(FieldKey field, InheritMap map, bool keepPublicApi, bool hidePrivateApi, out string skiprename)
        {
            // skip runtime methods
            if ((field.Field.IsRuntimeSpecialName && field.Field.Name == "value__"))
            {
                skiprename = "special name";
                return(true);
            }

            var attribute = field.Field.MarkedToRename();

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

            var parent = field.DeclaringType.MarkedToRename();

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

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

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

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

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

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

            skiprename = "HidePrivateApi option in configuration";
            return(!hidePrivateApi);
        }
Exemple #9
0
        public bool ShouldSkip(EventKey evt, InheritMap map)
        {
            if (ShouldSkip(evt.TypeKey, TypeSkipFlags.SkipEvent, map))
            {
                return(true);
            }

            return(skipEvents.IsMatch(evt, map));
        }
Exemple #10
0
        public bool ShouldSkip(PropertyKey prop, InheritMap map)
        {
            if (ShouldSkip(prop.TypeKey, TypeSkipFlags.SkipProperty, map))
            {
                return(true);
            }

            return(skipProperties.IsMatch(prop, map));
        }
Exemple #11
0
        public bool ShouldSkip(FieldKey field, InheritMap map)
        {
            if (ShouldSkip(field.TypeKey, TypeSkipFlags.SkipField, map))
            {
                return(true);
            }

            return(skipFields.IsMatch(field, map));
        }
Exemple #12
0
        public bool ShouldSkipStringHiding(MethodKey method, InheritMap map, bool hidePrivateApi)
        {
            if (ShouldSkip(method.TypeKey, TypeAffectFlags.SkipStringHiding, map))
            {
                return(true);
            }

            return(skipStringHiding.IsMatch(method, map));
        }
Exemple #13
0
        public bool ShouldSkip(TypeKey type, InheritMap map)
        {
            if (ShouldSkip(type.Namespace, map))
            {
                return(true);
            }

            return(skipTypes.IsMatch(type, map));
        }
Exemple #14
0
        public bool ShouldSkip(PropertyKey prop, InheritMap map, bool keepPublicApi, bool hidePrivateApi, out string skiprename)
        {
            if (prop.Property.IsRuntimeSpecialName)
            {
                skiprename = "runtime special name";
                return(true);
            }

            var attribute = prop.Property.MarkedToRename();

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

            var parent = prop.DeclaringType.MarkedToRename();

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

            if (ShouldForce(prop.TypeKey, TypeAffectFlags.AffectProperty, map))
            {
                skiprename = "type rule in configuration";
                return(false);
            }

            if (forceProperties.IsMatch(prop, map))
            {
                skiprename = "property rule in configuration";
                return(false);
            }

            if (ShouldSkip(prop.TypeKey, TypeAffectFlags.AffectProperty, map))
            {
                skiprename = "type rule in configuration";
                return(true);
            }

            if (skipProperties.IsMatch(prop, map))
            {
                skiprename = "property rule in configuration";
                return(true);
            }

            if (prop.DeclaringType.IsTruePublic() && (IsGetterPublic(prop.Property) || IsSetterPublic(prop.Property)))
            {
                skiprename = "KeepPublicApi option in configuration";
                return(keepPublicApi);
            }

            skiprename = "HidePrivateApi option in configuration";
            return(!hidePrivateApi);
        }
Exemple #15
0
        public bool Test(TypeKey type, InheritMap map)
        {
            if (!string.IsNullOrEmpty(attrib))
            {
                if (string.Equals(attrib, "public", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (!type.TypeDefinition.IsTypePublic())
                    {
                        return(false);
                    }
                }
                else
                {
                    throw new ObfuscarException(string.Format(
                                                    "'{0}' is not valid for the 'attrib' value of the SkipType element. Only 'public' is supported by now.",
                                                    attrib));
                }
            }

            // type's regex matches
            if (nameRx != null && !nameRx.IsMatch(type.Fullname))
            {
                return(false);
            }

            // type's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(type.Fullname, name))
            {
                return(false);
            }

            if (isSerializable.HasValue)
            {
                if (isSerializable != type.TypeDefinition.IsSerializable)
                {
                    return(false);
                }
            }

            if (isStatic.HasValue)
            {
                if (isStatic != (type.TypeDefinition.IsSealed && type.TypeDefinition.IsAbstract))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(inherits))
            {
                if (!map.Inherits(type.TypeDefinition, inherits))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #16
0
        public bool ShouldSkipStringHiding(MethodKey method, InheritMap map)
        {
            if (ShouldSkip(method.TypeKey, TypeSkipFlags.SkipStringHiding, map))
            {
                return(true);
            }

            return(skipStringHiding.IsMatch(method, map));
        }
Exemple #17
0
        public bool ShouldSkip(TypeKey type, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly,
                               out string message)
        {
            var attribute = type.TypeDefinition.MarkedToRename();

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

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

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

            if (ShouldForce(type.Namespace, map))
            {
                message = "namespace rule in configuration";
                return(false);
            }

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

            if (ShouldSkip(type.Namespace, map))
            {
                message = "namespace rule in configuration";
                return(true);
            }

            if (type.TypeDefinition.IsEnum && skipEnums)
            {
                message = "enum rule in configuration";
                return(true);
            }

            if (type.TypeDefinition.IsTypePublic())
            {
                message = "KeepPublicApi option in configuration";
                return(keepPublicApi);
            }

            message = "HidePrivateApi option in configuration";
            return(!hidePrivateApi);
        }
        public bool IsMatch(T thing, InheritMap map = null)
        {
            foreach (IPredicate <T> test in this)
            {
                if (test.Test(thing, map))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #19
0
        public bool Test(MethodKey method, InheritMap map)
        {
            if (key != null)
            {
                return(method == key);
            }

            // method name matches type regex?
            if (!String.IsNullOrEmpty(type) && !Helper.CompareOptionalRegex(method.TypeKey.Fullname, type))
            {
                return(false);
            }

            // method visibility matches
            if (CheckMemberVisibility(this.attrib, typeAttrib, method.MethodAttributes, method.DeclaringType))
            {
                return(false);
            }

            // method's name matches
            if (nameRx != null && !nameRx.IsMatch(method.Name))
            {
                return(false);
            }

            // method's name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(method.Name, name))
            {
                return(false);
            }

            // check is method's static flag matches.
            if (isStatic.HasValue)
            {
                bool methodIsStatic = (method.MethodAttributes & MethodAttributes.Static) == MethodAttributes.Static;

                if (isStatic != methodIsStatic)
                {
                    return(false);
                }
            }

            // finally does method's type inherit?
            if (!string.IsNullOrEmpty(inherits))
            {
                if (!map.Inherits(method.DeclaringType, inherits))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #20
0
        public bool ShouldSkip(MethodKey method, InheritMap map, bool keepPublicApi, bool hidePrivateApi)
        {
            if (ShouldSkip(method.TypeKey, TypeSkipFlags.SkipMethod, map, hidePrivateApi))
            {
                return(true);
            }

            if (skipMethods.IsMatch(method, map))
            {
                return(true);
            }

            return(method.ShouldSkip(keepPublicApi, hidePrivateApi));
        }
Exemple #21
0
        public bool ShouldSkip(PropertyKey prop, InheritMap map, bool keepPublicApi, bool hidePrivateApi)
        {
            if (ShouldSkip(prop.TypeKey, TypeSkipFlags.SkipProperty, map, hidePrivateApi))
            {
                return(true);
            }

            if (skipProperties.IsMatch(prop, map))
            {
                return(true);
            }

            return(prop.ShouldSkip(keepPublicApi, hidePrivateApi));
        }
Exemple #22
0
        public bool ShouldSkip(EventKey evt, InheritMap map, bool keepPublicApi, bool hidePrivateApi)
        {
            if (ShouldSkip(evt.TypeKey, TypeSkipFlags.SkipEvent, map, hidePrivateApi))
            {
                return(true);
            }

            if (skipEvents.IsMatch(evt, map))
            {
                return(true);
            }

            return(evt.ShouldSkip(keepPublicApi, hidePrivateApi));
        }
Exemple #23
0
        public bool ShouldSkip(FieldKey field, InheritMap map, bool keepPublicApi, bool hidePrivateApi)
        {
            if (ShouldSkip(field.TypeKey, TypeSkipFlags.SkipField, map, hidePrivateApi))
            {
                return(true);
            }

            if (skipFields.IsMatch(field, map))
            {
                return(true);
            }

            return(field.ShouldSkip(keepPublicApi, hidePrivateApi));
        }
Exemple #24
0
        public bool Test(string ns, InheritMap map)
        {
            // regex matches
            if (nameRx != null && !nameRx.IsMatch(ns))
            {
                return(false);
            }

            // name matches
            if (!string.IsNullOrEmpty(name) && !Helper.CompareOptionalRegex(ns, name))
            {
                return(false);
            }

            return(true);
        }
Exemple #25
0
        public bool Test(PropertyKey prop, InheritMap map)
        {
            if (Helper.CompareOptionalRegex(prop.TypeKey.Fullname, type) && !MethodTester.CheckMemberVisibility(attrib, typeAttrib, prop.GetterMethodAttributes, prop.DeclaringType))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(prop.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(prop.Name));
                }
            }

            return(false);
        }
Exemple #26
0
        public bool Test(EventKey evt, InheritMap map)
        {
            if (Helper.CompareOptionalRegex(evt.TypeKey.Fullname, type) && MethodTester.CheckMemberVisibility(attrib, typeAttrib, evt.AddMethodAttributes, evt.DeclaringType))
            {
                if (name != null)
                {
                    return(Helper.CompareOptionalRegex(evt.Name, name));
                }
                else
                {
                    return(nameRx.IsMatch(evt.Name));
                }
            }

            return(false);
        }
Exemple #27
0
        public bool ShouldSkip(TypeKey type, TypeSkipFlags flag, InheritMap map)
        {
            if (ShouldSkip(type.Namespace, map))
            {
                return(true);
            }

            foreach (TypeTester typeTester in skipTypes)
            {
                if ((typeTester.SkipFlags & flag) > 0 && typeTester.Test(type, map))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #28
0
        private bool ShouldForce(TypeKey type, TypeAffectFlags flag, InheritMap map)
        {
            if (ShouldForce(type.Namespace, map))
            {
                return(true);
            }

            foreach (TypeTester typeTester in forceTypes)
            {
                if ((typeTester.AffectFlags & flag) > 0 && typeTester.Test(type, map))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #29
0
        public bool ShouldSkip(MethodKey method, InheritMap map, bool keepPublicApi, bool hidePrivateApi,
                               bool markedOnly, out string message)
        {
            if (method.Method.IsRuntime)
            {
                message = "runtime method";
                return(true);
            }

            if (method.Method.IsSpecialName)
            {
                switch (method.Method.SemanticsAttributes)
                {
                case MethodSemanticsAttributes.None:
                    // Do nothing, most likely this is a dangling accessor method without
                    // associated event or property
                    break;

                case MethodSemanticsAttributes.Getter:
                case MethodSemanticsAttributes.Setter:
                    message = "skipping properties";
                    if (!project.Settings.RenameProperties)
                    {
                        return(true);
                    }

                    break;

                case MethodSemanticsAttributes.AddOn:
                case MethodSemanticsAttributes.RemoveOn:
                    message = "skipping events";
                    if (!project.Settings.RenameEvents)
                    {
                        return(true);
                    }

                    break;

                default:
                    message = "special name";
                    return(true);
                }
            }

            return(ShouldSkipParams(method, map, keepPublicApi, hidePrivateApi, markedOnly, out message));
        }
Exemple #30
0
        public bool ShouldSkip(TypeKey type, InheritMap map, bool keepPublicApi, bool hidePrivateApi)
        {
            if (skipTypes.IsMatch(type, map))
            {
                return(true);
            }

            if (ShouldSkip(type.Namespace, map))
            {
                //if (type.TypeDefinition.IsPublic) {
                //	return keepPublicApi;
                //}

                if (!hidePrivateApi)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #31
0
		public bool ShouldSkip(TypeKey type, TypeSkipFlags flag, InheritMap map)
		{
			if (ShouldSkip(type.Namespace, map))
				return true;

			foreach (TypeTester typeTester in skipTypes)
			{
				if ((typeTester.SkipFlags & flag) > 0 && typeTester.Test(type, map))
					return true;
			}

			return false;
		}
Exemple #32
0
        public bool ShouldSkipStringHiding(MethodKey method, InheritMap map, bool projectHideStrings)
        {
            if (ShouldForce (method.TypeKey, TypeAffectFlags.AffectString, map))
                return false;

            if (forceStringHiding.IsMatch (method, map))
                return false;

            if (ShouldSkip (method.TypeKey, TypeAffectFlags.AffectString, map))
                return true;

            if (skipStringHiding.IsMatch (method, map))
                return true;

            return !projectHideStrings;
        }
Exemple #33
0
		public bool ShouldSkip(TypeKey type, InheritMap map)
		{
			if (ShouldSkip(type.Namespace, map))
				return true;

			return skipTypes.IsMatch(type, map);
		}
Exemple #34
0
		public bool ShouldSkip(PropertyKey prop, InheritMap map)
		{
			if (ShouldSkip(prop.TypeKey, TypeSkipFlags.SkipProperty, map))
				return true;

			return skipProperties.IsMatch(prop, map);
		}
Exemple #35
0
        private bool ShouldSkip(TypeKey type, TypeAffectFlags flag, InheritMap map)
        {
            if (ShouldSkip (type.Namespace, map)) {
                return true;
            }

            foreach (TypeTester typeTester in skipTypes) {
                if ((typeTester.AffectFlags & flag) > 0 && typeTester.Test (type, map))
                    return true;
            }

            return false;
        }
Exemple #36
0
        public bool ShouldSkipStringHiding(MethodKey method, InheritMap map, bool projectHideStrings)
        {
            if (method.DeclaringType.IsResourcesType () && method.Method.ReturnType.FullName == "System.Resources.ResourceManager")
                return true; // IMPORTANT: avoid hiding resource type name, as it might be renamed later.

            if (ShouldForce (method.TypeKey, TypeAffectFlags.AffectString, map))
                return false;

            if (forceStringHiding.IsMatch (method, map))
                return false;

            if (ShouldSkip (method.TypeKey, TypeAffectFlags.AffectString, map))
                return true;

            if (skipStringHiding.IsMatch (method, map))
                return true;

            return !projectHideStrings;
        }
Exemple #37
0
 private bool ShouldForce(string ns, InheritMap map)
 {
     return forceNamespaces.IsMatch (ns, map);
 }
Exemple #38
0
        public bool ShouldSkip(EventKey evt, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            // skip runtime special events
            if (evt.Event.IsRuntimeSpecialName) {
                message = "runtime special name";
                return true;
            }

            var attribute = evt.Event.MarkedToRename ();
            // skip runtime methods
            if (attribute != null) {
                message = "attribute";
                return !attribute.Value;
            }

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

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

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

            if (forceEvents.IsMatch (evt, map)) {
                message = "event rule in configuration";
                return false;
            }

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

            if (skipEvents.IsMatch (evt, map)) {
                message = "event rule in configuration";
                return true;
            }

            if (evt.DeclaringType.IsTypePublic () && evt.Event.IsPublic ()) {
                message = "KeepPublicApi option in configuration";
                return keepPublicApi;
            }

            message = "HidePrivateApi option in configuration";
            return !hidePrivateApi;
        }
Exemple #39
0
        public bool ShouldSkipParams(MethodKey method, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            var attribute = method.Method.MarkedToRename ();
            // skip runtime methods
            if (attribute != null) {
                message = "attribute";
                return !attribute.Value;
            }

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

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

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

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

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

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

            if (method.DeclaringType.IsTypePublic () && method.Method.IsPublic ()) {
                message = "KeepPublicApi option in configuration";
                return keepPublicApi;
            }

            message = "HidePrivateApi option in configuration";
            return !hidePrivateApi;
        }
Exemple #40
0
        public bool ShouldSkip(PropertyKey prop, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            if (prop.Property.IsRuntimeSpecialName) {
                message = "runtime special name";
                return true;
            }

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

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

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

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

            if (forceProperties.IsMatch (prop, map)) {
                message = "property rule in configuration";
                return false;
            }

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

            if (skipProperties.IsMatch (prop, map)) {
                message = "property rule in configuration";
                return true;
            }

            if (prop.DeclaringType.IsTypePublic () && prop.Property.IsPublic ()) {
                message = "KeepPublicApi option in configuration";
                return keepPublicApi;
            }

            message = "HidePrivateApi option in configuration";
            return !hidePrivateApi;
        }
Exemple #41
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;
        }
Exemple #42
0
		public bool ShouldSkipStringHiding(MethodKey method, InheritMap map)
		{
			if (ShouldSkip(method.TypeKey, TypeSkipFlags.SkipStringHiding, map))
				return true;

			return skipStringHiding.IsMatch(method, map);
		}
Exemple #43
0
		public bool ShouldSkipStringHiding (MethodKey method, InheritMap map, bool hidePrivateApi)
		{
			if (ShouldSkip (method.TypeKey, TypeAffectFlags.SkipStringHiding, map))
				return true;

			return skipStringHiding.IsMatch (method, map);
		}
Exemple #44
0
 private bool ShouldSkip(string ns, InheritMap map)
 {
     return skipNamespaces.IsMatch (ns, map);
 }
Exemple #45
0
        public bool ShouldSkip(TypeKey type, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            var attribute = type.TypeDefinition.MarkedToRename ();
            if (attribute != null) {
                message = "attribute";
                return !attribute.Value;
            }

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

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

            if (ShouldForce (type.Namespace, map)) {
                message = "namespace rule in configuration";
                return false;
            }

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

            if (ShouldSkip (type.Namespace, map)) {
                message = "namespace rule in configuration";
                return true;
            }

            if (type.TypeDefinition.IsEnum && skipEnums) {
                message = "enum rule in configuration";
                return true;
            }

            if (type.TypeDefinition.IsTypePublic ()) {
                message = "KeepPublicApi option in configuration";
                return keepPublicApi;
            }

            message = "HidePrivateApi option in configuration";
            return !hidePrivateApi;
        }
Exemple #46
0
		public bool ShouldSkip(EventKey evt, InheritMap map)
		{
			if (ShouldSkip(evt.TypeKey, TypeSkipFlags.SkipEvent, map))
				return true;

			return skipEvents.IsMatch(evt, map);
		}
Exemple #47
0
		public bool ShouldSkip(FieldKey field, InheritMap map)
		{
			if (ShouldSkip(field.TypeKey, TypeSkipFlags.SkipField, map))
				return true;

			return skipFields.IsMatch(field, map);
		}
Exemple #48
0
        public bool ShouldSkip(MethodKey method, InheritMap map, bool keepPublicApi, bool hidePrivateApi, bool markedOnly, out string message)
        {
            if (method.Method.IsRuntime) {
                message = "runtime method";
                return true;
            }

            if (method.Method.IsSpecialName) {
                switch (method.Method.SemanticsAttributes) {
                case MethodSemanticsAttributes.Getter:
                case MethodSemanticsAttributes.Setter:
                    message = "skipping properties";
                    return !project.Settings.RenameProperties;
                case MethodSemanticsAttributes.AddOn:
                case MethodSemanticsAttributes.RemoveOn:
                    message = "skipping events";
                    return !project.Settings.RenameEvents;
                default:
                    message = "special name";
                    return true;
                }
            }

            return ShouldSkipParams (method, map, keepPublicApi, hidePrivateApi, markedOnly, out message);
        }