Esempio n. 1
0
        static internal object[] GetDebugAttributes(IMetadataImport importer, int token)
        {
            ArrayList attributes = new ArrayList();
            object    attr       = MetadataHelperFunctions.GetCustomAttribute(importer, token, typeof(System.Diagnostics.DebuggerTypeProxyAttribute));

            if (attr != null)
            {
                attributes.Add(attr);
            }
            attr = MetadataHelperFunctions.GetCustomAttribute(importer, token, typeof(System.Diagnostics.DebuggerDisplayAttribute));
            if (attr != null)
            {
                attributes.Add(attr);
            }
            attr = MetadataHelperFunctions.GetCustomAttribute(importer, token, typeof(System.Diagnostics.DebuggerBrowsableAttribute));
            if (attr != null)
            {
                attributes.Add(attr);
            }
            attr = MetadataHelperFunctions.GetCustomAttribute(importer, token, typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute));
            if (attr != null)
            {
                attributes.Add(attr);
            }

            if (attributes.Count == 0)
            {
                return(emptyAttributes);
            }
            else
            {
                return(attributes.ToArray());
            }
        }
Esempio n. 2
0
        internal MetadataPropertyInfo(IMetadataImport importer, int propertyToken, MetadataType declaringType)
        {
            m_importer      = importer;
            m_propertyToken = propertyToken;
            m_declaringType = declaringType;

            int    mdTypeDef;
            int    pchProperty;
            int    pdwPropFlags;
            IntPtr ppvSig;
            int    pbSig;
            int    pdwCPlusTypeFlag;
            IntPtr ppDefaultValue;
            int    pcchDefaultValue;
            int    rmdOtherMethod;
            int    pcOtherMethod;

            m_importer.GetPropertyProps(
                m_propertyToken,
                out mdTypeDef,
                null,
                0,
                out pchProperty,
                out pdwPropFlags,
                out ppvSig,
                out pbSig,
                out pdwCPlusTypeFlag,
                out ppDefaultValue,
                out pcchDefaultValue,
                out m_pmdSetter,
                out m_pmdGetter,
                out rmdOtherMethod,
                0,
                out pcOtherMethod);

            StringBuilder szProperty = new StringBuilder(pchProperty);

            m_importer.GetPropertyProps(
                m_propertyToken,
                out mdTypeDef,
                szProperty,
                pchProperty,
                out pchProperty,
                out pdwPropFlags,
                out ppvSig,
                out pbSig,
                out pdwCPlusTypeFlag,
                out ppDefaultValue,
                out pcchDefaultValue,
                out m_pmdSetter,
                out m_pmdGetter,
                out rmdOtherMethod,
                0,
                out pcOtherMethod);

            m_propAttributes = (PropertyAttributes)pdwPropFlags;
            m_name           = szProperty.ToString();
            MetadataHelperFunctions.GetCustomAttribute(importer, propertyToken, typeof(System.Diagnostics.DebuggerBrowsableAttribute));
        }
Esempio n. 3
0
        internal MetadataFieldInfo(IMetadataImport importer, int fieldToken, MetadataType declaringType)
        {
            m_importer      = importer;
            m_fieldToken    = fieldToken;
            m_declaringType = declaringType;

            // Initialize
            int    mdTypeDef;
            int    pchField, pcbSigBlob, pdwCPlusTypeFlab, pcchValue, pdwAttr;
            IntPtr ppvSigBlob;
            IntPtr ppvRawValue;

            m_importer.GetFieldProps(m_fieldToken,
                                     out mdTypeDef,
                                     null,
                                     0,
                                     out pchField,
                                     out pdwAttr,
                                     out ppvSigBlob,
                                     out pcbSigBlob,
                                     out pdwCPlusTypeFlab,
                                     out ppvRawValue,
                                     out pcchValue
                                     );

            StringBuilder szField = new StringBuilder(pchField);

            m_importer.GetFieldProps(m_fieldToken,
                                     out mdTypeDef,
                                     szField,
                                     szField.Capacity,
                                     out pchField,
                                     out pdwAttr,
                                     out ppvSigBlob,
                                     out pcbSigBlob,
                                     out pdwCPlusTypeFlab,
                                     out ppvRawValue,
                                     out pcchValue
                                     );
            m_fieldAttributes = (FieldAttributes)pdwAttr;
            m_name            = szField.ToString();

            // Get the values for static literal fields with primitive types
            FieldAttributes staticLiteralField = FieldAttributes.Static | FieldAttributes.HasDefault | FieldAttributes.Literal;

            if ((m_fieldAttributes & staticLiteralField) == staticLiteralField)
            {
                m_value = ParseDefaultValue(declaringType, ppvSigBlob, ppvRawValue);
            }
            // [Xamarin] Expression evaluator.
            MetadataHelperFunctions.GetCustomAttribute(importer, m_fieldToken, typeof(System.Diagnostics.DebuggerBrowsableAttribute));
        }