Exemplo n.º 1
0
        static DebuggerBrowsableState?GetDebuggerBrowsableState(IMetaDataImport mdi, uint token)
        {
            Debug.Assert(new MDToken(token).Table == Table.Field || new MDToken(token).Table == Table.Property);
            if (mdi == null)
            {
                return(null);
            }

            var       data           = MDAPI.GetCustomAttributeByName(mdi, token, "System.Diagnostics.DebuggerBrowsableAttribute");
            const int expectedLength = 8;

            if (data == null || data.Length != expectedLength)
            {
                return(null);
            }
            if (BitConverter.ToUInt16(data, 0) != 1)
            {
                return(null);
            }
            var state = (DebuggerBrowsableState)BitConverter.ToInt32(data, 2);

            if (BitConverter.ToUInt16(data, 6) != 0)
            {
                return(null);
            }

            return(state);
        }