コード例 #1
0
        /// <summary>
        /// Check member for obfuscation attribute, and store result in output list
        /// </summary>
        /// <param name="typeToScan">Type currently scanned</param>
        /// <param name="curMember">Member to be scanned for obfuscation attributes</param>
        /// <param name="defaultValue">Default value of obfuscation</param>
        /// <param name="result">List in which result are transmitted</param>
        private void CheckMemberAndApplyResults(TypeDefinition typeToScan, IMemberDefinition curMember, bool?defaultValue, List <Configuration.SkipBase> result)
        {
            // Only methods of class are to be excluded
            if (curMember.DeclaringType.FullName.Equals(typeToScan.FullName))
            {
                bool toExclude = defaultValue.GetValueOrDefault(false);
                System.Reflection.ObfuscationAttribute toFind = this.GetAndStripObfuscationCustomAttribute(curMember);
                if (toFind != null)
                {
                    // We have found an Obfuscation attribute, default value doesn't apply
                    toExclude = toFind.Exclude;
                }

                if (toExclude)
                {
                    Configuration.SkipElement toAdd = null;
                    switch (curMember.GetType().FullName)
                    {
                    case "Mono.Cecil.EventDefinition":
                        toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipEvent();
                        break;

                    case "Mono.Cecil.FieldDefinition":
                        toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipField();
                        break;

                    case "Mono.Cecil.PropertyDefinition":
                        toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipProperty();
                        break;

                    case "Mono.Cecil.MethodDefinition":
                        toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipMethod();
                        break;

                    default:
                        throw new NotImplementedException(string.Format("Type {0} is not suppported", curMember.GetType().FullName));
                    }

                    toAdd.Type = typeToScan.FullName;
                    toAdd.Name = curMember.Name;
                    result.Add(toAdd);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Check member for obfuscation attribute, and store result in output list
        /// </summary>
        /// <param name="typeToScan">Type currently scanned</param>
        /// <param name="curMember">Member to be scanned for obfuscation attributes</param>
        /// <param name="defaultValue">Default value of obfuscation</param>
        /// <param name="result">List in which result are transmitted</param>
        private void CheckMemberAndApplyResults(TypeDefinition typeToScan, IMemberDefinition curMember, bool? defaultValue, List<Configuration.SkipBase> result)
        {
            // Only methods of class are to be excluded
            if (curMember.DeclaringType.FullName.Equals(typeToScan.FullName))
            {
                bool toExclude = defaultValue.GetValueOrDefault(false);
                System.Reflection.ObfuscationAttribute toFind = this.GetAndStripObfuscationCustomAttribute(curMember);
                if (toFind != null)
                {
                    // We have found an Obfuscation attribute, default value doesn't apply
                    toExclude = toFind.Exclude;
                }

                if (toExclude)
                {
                    Configuration.SkipElement toAdd = null;
                    switch (curMember.GetType().FullName)
                    {
                        case "Mono.Cecil.EventDefinition":
                            toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipEvent();
                            break;
                        case "Mono.Cecil.FieldDefinition":
                            toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipField();
                            break;
                        case "Mono.Cecil.PropertyDefinition":
                            toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipProperty();
                            break;
                        case "Mono.Cecil.MethodDefinition":
                            toAdd = new ObfuscarStandardAttributeHelper.Core.Configuration.SkipMethod();
                            break;
                        default:
                            throw new NotImplementedException(string.Format("Type {0} is not suppported", curMember.GetType().FullName));
                    }

                    toAdd.Type = typeToScan.FullName;
                    toAdd.Name = curMember.Name;
                    result.Add(toAdd);
                }
            }
        }