Exemplo n.º 1
0
        // The only purpose of this method is to get type name of the method and declaring type token (opaque for SymWriter), everything else is ignored by the SymWriter.
        // "mb" is the token passed to OpenMethod. The token is remembered until the corresponding CloseMethod, which passes it to GetMethodProps.
        // It's opaque for SymWriter.
        unsafe uint IMetaDataImport.GetMethodProps(uint mb, out uint pointerClass, IntPtr stringMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr,
                                                   IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA)
        {
            IMethodDefinition m = this.writer.GetMethodDefinition(mb);

            pchMethod    = 0;
            pointerClass = 0;
            pointerClass = this.writer.GetTypeToken(m.GetContainingType(this.writer.Context));
            string methName = m.Name;

            pchMethod = (uint)methName.Length;
            if (pchMethod > cchMethod)
            {
                pchMethod = cchMethod - 1;
            }

            char *pointerMethName = (char *)stringMethod.ToPointer();

            for (int i = 0; i < pchMethod; i++)
            {
                *(pointerMethName + i) = methName[i];
            }

            *(pointerMethName + pchMethod) = (char)0;
            return(0);
        }
Exemplo n.º 2
0
        // The only purpose of this method is to get type name of the method and declaring type token (opaque for SymWriter), everything else is ignored by the SymWriter.
        // "mb" is the token passed to OpenMethod. The token is remembered until the corresponding CloseMethod, which passes it to GetMethodProps.
        // It's opaque for SymWriter.
        unsafe uint IMetaDataImport.GetMethodProps(uint mb, out uint pointerClass, IntPtr stringMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr,
                                                   IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA)
        {
            IMethodDefinition m = _writer.GetMethodDefinition(mb);

            pchMethod    = 0;
            pointerClass = 0;
            pointerClass = _writer.GetTypeToken(m.GetContainingType(_writer.Context));
            string methName = m.Name;

            // if the buffer is too small to fit the name, truncate the name
            uint nameLengthIncludingNull = Math.Min((uint)methName.Length + 1, cchMethod);

            // we shall return the length of the name not including NUL
            pchMethod = nameLengthIncludingNull - 1;

            char *pointerMethName = (char *)stringMethod.ToPointer();

            for (int i = 0; i < pchMethod; i++)
            {
                *(pointerMethName + i) = methName[i];
            }

            *(pointerMethName + pchMethod) = (char)0;
            return(0);
        }
Exemplo n.º 3
0
        public bool TryGetMethodInfo(int methodDefinitionToken, out string methodName, out int declaringTypeToken)
        {
            IMethodDefinition m = _writer.GetMethodDefinition(methodDefinitionToken);

            methodName         = m.Name;
            declaringTypeToken = MetadataTokens.GetToken(_writer.GetTypeHandle(m.GetContainingType(_writer.Context)));
            return(true);
        }