Exemplo n.º 1
0
        private bool IsBlockedCustomAttribute(Cts.MethodDesc constructor, Ecma.Decoding.CustomAttributeValue <Cts.TypeDesc> decodedValue)
        {
            if (IsBlocked(constructor.OwningType))
            {
                return(true);
            }

            foreach (var fixedArgument in decodedValue.FixedArguments)
            {
                if (IsBlockedCustomAttributeConstantValue(fixedArgument.Type, fixedArgument.Value))
                {
                    return(true);
                }

                if (fixedArgument.Type.IsEnum && IsBlocked(fixedArgument.Type))
                {
                    return(true);
                }
            }

            foreach (var namedArgument in decodedValue.NamedArguments)
            {
                if (IsBlockedCustomAttributeConstantValue(namedArgument.Type, namedArgument.Value))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private CustomAttribute HandleCustomAttribute(Cts.MethodDesc constructor, Ecma.Decoding.CustomAttributeValue <Cts.TypeDesc> decodedValue)
        {
            CustomAttribute result = new CustomAttribute
            {
                Constructor = HandleQualifiedMethod(constructor),
            };

            result.FixedArguments.Capacity = decodedValue.FixedArguments.Length;
            foreach (var decodedArgument in decodedValue.FixedArguments)
            {
                var fixedArgument = new FixedArgument
                {
                    Type  = HandleType(decodedArgument.Type),
                    Value = HandleCustomAttributeConstantValue(decodedArgument.Type, decodedArgument.Value),
                };
                result.FixedArguments.Add(fixedArgument);
            }

            result.NamedArguments.Capacity = decodedValue.NamedArguments.Length;
            foreach (var decodedArgument in decodedValue.NamedArguments)
            {
                var namedArgument = new NamedArgument
                {
                    Flags = decodedArgument.Kind == Ecma.CustomAttributeNamedArgumentKind.Field ?
                            NamedArgumentMemberKind.Field : NamedArgumentMemberKind.Property,
                    Name  = HandleString(decodedArgument.Name),
                    Value = new FixedArgument
                    {
                        Type  = HandleType(decodedArgument.Type),
                        Value = HandleCustomAttributeConstantValue(decodedArgument.Type, decodedArgument.Value)
                    }
                };
                result.NamedArguments.Add(namedArgument);
            }

            return(result);
        }