Example #1
0
 protected DmdParameterDef(uint rid, DmdMemberInfo member, int position, DmdType parameterType)
 {
     this.rid      = rid;
     Member        = member ?? throw new ArgumentNullException(nameof(member));
     Position      = position;
     ParameterType = parameterType ?? throw new ArgumentNullException(nameof(parameterType));
 }
Example #2
0
 public MemberValueNodeInfo(DmdMemberInfo member, byte inheritanceLevel)
 {
     Member           = member;
     InheritanceLevel = inheritanceLevel;
     Flags            = GetFlags(member);
     // The caller initializes it later
     Name = default;
 }
Example #3
0
 public static bool IsMatch(DmdMemberInfo member, string name, DmdBindingFlags bindingAttr)
 {
     if ((bindingAttr & DmdBindingFlags.IgnoreCase) != 0)
     {
         return(StringComparer.OrdinalIgnoreCase.Equals(member.Name, name));
     }
     return(StringComparer.Ordinal.Equals(member.Name, name));
 }
Example #4
0
        static MemberValueNodeInfoFlags GetFlags(DmdMemberInfo member)
        {
            var flags = GetInfoFlags(member);

            // We don't check System.Runtime.CompilerServices.CompilerGeneratedAttribute. This matches VS (Roslyn) behavior.
            if (Microsoft.CodeAnalysis.ExpressionEvaluator.GeneratedMetadataNames.IsCompilerGenerated(member.Name))
            {
                flags |= MemberValueNodeInfoFlags.CompilerGeneratedName;
            }
            var cas = member.CustomAttributes;

            for (int i = 0; i < cas.Count; i++)
            {
                var ca   = cas[i];
                var type = ca.AttributeType;
                switch (type.MetadataName)
                {
                case nameof(DebuggerBrowsableAttribute):
                    if (type.MetadataNamespace == "System.Diagnostics")
                    {
                        if (ca.ConstructorArguments.Count == 1)
                        {
                            var arg = ca.ConstructorArguments[0];
                            if (arg.Value is int)
                            {
                                flags &= ~MemberValueNodeInfoFlags.DebuggerBrowsableState_Mask;
                                switch ((DebuggerBrowsableState)(int)arg.Value)
                                {
                                case DebuggerBrowsableState.Never:
                                    flags |= MemberValueNodeInfoFlags.DebuggerBrowsableState_Never;
                                    break;

                                case DebuggerBrowsableState.RootHidden:
                                    flags |= MemberValueNodeInfoFlags.DebuggerBrowsableState_RootHidden;
                                    break;
                                }
                            }
                        }
                    }
                    break;

                case nameof(ObsoleteAttribute):
                    if (type.MetadataNamespace == "System")
                    {
                        if (ca.ConstructorArguments.Count == 2 && ca.ConstructorArguments[0].ArgumentType == member.AppDomain.System_String)
                        {
                            var arg = ca.ConstructorArguments[1];
                            if (arg.Value is bool && (bool)arg.Value)
                            {
                                flags |= MemberValueNodeInfoFlags.DeprecatedError;
                            }
                        }
                    }
                    break;
                }
            }
            return(flags);
        }
Example #5
0
        void WriteToken(DmdMemberInfo member)
        {
            if (!Tokens)
            {
                return;
            }
            var primitiveFormatter = new CSharpPrimitiveValueFormatter(output, GetValueFormatterOptions() & ~ValueFormatterOptions.Decimal, cultureInfo);
            var tokenString        = primitiveFormatter.ToFormattedUInt32((uint)member.MetadataToken);

            OutputWrite(CommentBegin + tokenString + CommentEnd, BoxedTextColor.Comment);
        }
Example #6
0
        static MemberValueNodeInfoFlags GetFlags(DmdMemberInfo member)
        {
            var flags = GetInfoFlags(member);

            // We don't check System.Runtime.CompilerServices.CompilerGeneratedAttribute. This matches VS (Roslyn) behavior.
            if (RoslynHelpers.IsCompilerGenerated(member.Name))
            {
                flags |= MemberValueNodeInfoFlags.CompilerGeneratedName;
            }
            var cas = member.CustomAttributes;

            for (int i = 0; i < cas.Count; i++)
            {
                var ca   = cas[i];
                var type = ca.AttributeType;
                switch (type.MetadataName)
                {
                case "DebuggerBrowsableAttribute":
                    if (type.MetadataNamespace == "System.Diagnostics")
                    {
                        if (ca.ConstructorArguments.Count == 1)
                        {
                            var arg = ca.ConstructorArguments[0];
                            if (arg.Value is int)
                            {
                                flags = flags & ~MemberValueNodeInfoFlags.DebuggerBrowsableState_Mask;
                                switch ((DebuggerBrowsableState)(int)arg.Value)
                                {
                                case DebuggerBrowsableState.Never:
                                    flags |= MemberValueNodeInfoFlags.DebuggerBrowsableState_Never;
                                    break;

                                case DebuggerBrowsableState.RootHidden:
                                    flags |= MemberValueNodeInfoFlags.DebuggerBrowsableState_RootHidden;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
            }
            return(flags);
        }
Example #7
0
        static MemberValueNodeInfoFlags GetInfoFlags(DmdMemberInfo member)
        {
            Debug.Assert(member.MemberType == DmdMemberTypes.Field || member.MemberType == DmdMemberTypes.Property);
            MemberValueNodeInfoFlags res = MemberValueNodeInfoFlags.None;

            switch (member.MemberType)
            {
            case DmdMemberTypes.Field:
                var field = ((DmdFieldInfo)member);
                if (field.IsPublic)
                {
                    res |= MemberValueNodeInfoFlags.Public;
                }
                else if ((field.IsPrivate || field.IsPrivateScope) && field.DeclaringType != field.ReflectedType)
                {
                    res |= MemberValueNodeInfoFlags.NeedCast;
                }
                return(res);

            case DmdMemberTypes.Property:
                var prop     = (DmdPropertyInfo)member;
                var accessor = prop.GetGetMethod(DmdGetAccessorOptions.All) ?? prop.GetSetMethod(DmdGetAccessorOptions.All);
                if (!(accessor is null))
                {
                    if (accessor.IsPublic)
                    {
                        res |= MemberValueNodeInfoFlags.Public;
                    }
                    else if ((accessor.IsPrivate || accessor.IsPrivateScope) && accessor.DeclaringType != accessor.ReflectedType)
                    {
                        res |= MemberValueNodeInfoFlags.NeedCast;
                    }
                }
                return(res);

            default:
                throw new InvalidOperationException();
            }
        }
Example #8
0
 public DmdParameterDefMD(DmdEcma335MetadataReader reader, uint rid, string name, DmdParameterAttributes attributes, DmdMemberInfo member, int position, DmdType parameterType) : base(rid, member, position, parameterType)
 {
     this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
     Name        = name;     // Null is allowed
     Attributes  = attributes;
 }
Example #9
0
 public DmdCreatedParameterDef(DmdMemberInfo member, int position, DmdType parameterType) : base(0, member, position, parameterType)
 {
 }
 static DmdMemberInfo TryResolve(DmdMemberInfo member, DmdResolveOptions options) => (options & DmdResolveOptions.NoTryResolveRefs) != 0 ? member : member.ResolveMemberNoThrow() ?? member;
 public DmdCreatedParameterInfo(DmdMemberInfo member, DmdParameterInfo originalParameter, DmdType parameterType)
 {
     Member = member ?? throw new ArgumentNullException(nameof(member));
     this.originalParameter = originalParameter ?? throw new ArgumentNullException(nameof(originalParameter));
     ParameterType          = parameterType ?? throw new ArgumentNullException(nameof(parameterType));
 }
Example #12
0
 AppDomainMirror GetMonoAppDomain(DmdMemberInfo member) => DbgMonoDebugInternalAppDomainImpl.GetAppDomainMirror(member.AppDomain);
 public DmdPropertyParameter(DmdPropertyDef property, DmdParameterInfo parameter)
 {
     Member         = property ?? throw new ArgumentNullException(nameof(property));
     this.parameter = parameter ?? throw new ArgumentNullException(nameof(parameter));
 }
Example #14
0
 public DmdParameterDefCOMD(DmdComMetadataReader reader, uint rid, string?name, DmdParameterAttributes attributes, DmdMemberInfo member, int position, DmdType parameterType) : base(rid, member, position, parameterType)
 {
     this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
     reader.Dispatcher.VerifyAccess();
     Name       = name;      // Null is allowed
     Attributes = attributes;
 }