Example #1
0
        public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor)
        {
            uint memberFunctionIdTypeIndex = _blob.GetNextTypeIndex();

            Utf8String name       = new Utf8String(memberIdDescriptor.Name);
            uint       recordSize = 12 + DebugInfoBlob.StringLengthEncoded(name);

            _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
            _blob.WriteLeafKind(LeafKind.LF_MFUNC_ID);
            _blob.WriteDWORD(memberIdDescriptor.MemberFunction);
            _blob.WriteDWORD(memberIdDescriptor.ParentClass);
            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
            return(memberFunctionIdTypeIndex);
        }
        // Get type index for specific method by name
        public uint GetMethodFunctionIdTypeIndex(MethodDesc method)
        {
            lock (_lock)
            {
                uint typeIndex;

                if (_methodIdIndices.TryGetValue(method, out typeIndex))
                {
                    return(typeIndex);
                }

                MemberFunctionIdTypeDescriptor descriptor = new MemberFunctionIdTypeDescriptor();

                descriptor.MemberFunction = GetMethodTypeIndex(method);
                descriptor.ParentClass    = GetTypeIndex(method.OwningType, true);
                descriptor.Name           = method.Name;

                typeIndex = _objectWriter.GetMemberFunctionId(descriptor);
                _methodIdIndices.Add(method, typeIndex);
                return(typeIndex);
            }
        }