示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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));
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#9
0
        public bool ShouldSkip(EventKey evt, InheritMap map)
        {
            if (ShouldSkip(evt.TypeKey, TypeSkipFlags.SkipEvent, map))
            {
                return(true);
            }

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

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

            return(skipFields.IsMatch(field, map));
        }
示例#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));
        }
示例#13
0
        public bool ShouldSkip(TypeKey type, InheritMap map)
        {
            if (ShouldSkip(type.Namespace, map))
            {
                return(true);
            }

            return(skipTypes.IsMatch(type, map));
        }
示例#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);
        }
示例#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);
        }
示例#16
0
        public bool ShouldSkipStringHiding(MethodKey method, InheritMap map)
        {
            if (ShouldSkip(method.TypeKey, TypeSkipFlags.SkipStringHiding, map))
            {
                return(true);
            }

            return(skipStringHiding.IsMatch(method, map));
        }
示例#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);
        }
示例#18
0
        public bool IsMatch(T thing, InheritMap map = null)
        {
            foreach (IPredicate <T> test in this)
            {
                if (test.Test(thing, map))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#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);
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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));
        }
示例#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);
        }
示例#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;
		}
示例#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;
        }
示例#33
0
		public bool ShouldSkip(TypeKey type, InheritMap map)
		{
			if (ShouldSkip(type.Namespace, map))
				return true;

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

			return skipProperties.IsMatch(prop, map);
		}
示例#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;
        }
示例#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;
        }
示例#37
0
 private bool ShouldForce(string ns, InheritMap map)
 {
     return forceNamespaces.IsMatch (ns, map);
 }
示例#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;
        }
示例#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;
        }
示例#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;
        }
示例#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;
        }
示例#42
0
		public bool ShouldSkipStringHiding(MethodKey method, InheritMap map)
		{
			if (ShouldSkip(method.TypeKey, TypeSkipFlags.SkipStringHiding, map))
				return true;

			return skipStringHiding.IsMatch(method, map);
		}
示例#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);
		}
示例#44
0
 private bool ShouldSkip(string ns, InheritMap map)
 {
     return skipNamespaces.IsMatch (ns, map);
 }
示例#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;
        }
示例#46
0
		public bool ShouldSkip(EventKey evt, InheritMap map)
		{
			if (ShouldSkip(evt.TypeKey, TypeSkipFlags.SkipEvent, map))
				return true;

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

			return skipFields.IsMatch(field, map);
		}
示例#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);
        }