Пример #1
0
        // The only purpose of this method is to get type name and "is nested" flag, everything else is ignored by the SymWriter.
        // "td" is token returned by GetMethodProps or GetNestedClassProps
        unsafe uint IMetaDataImport.GetTypeDefProps(uint td, IntPtr stringTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags)
        {
            pchTypeDef = 0;
            if (td == 0)
            {
                return(0);
            }

            // The typeDef name should be fully qualified
            ITypeDefinition t = _writer.GetTypeDefinition(td);
            string          typeDefName;

            if (_lastTypeDef == td)
            {
                typeDefName = _lastTypeDefName;
            }
            else
            {
                typeDefName = MetadataWriter.GetMangledName((INamedTypeReference)t);

                INamespaceTypeDefinition namespaceTypeDef;

                if ((namespaceTypeDef = t.AsNamespaceTypeDefinition(_writer.Context)) != null)
                {
                    typeDefName = CodeAnalysis.MetadataHelpers.BuildQualifiedName(namespaceTypeDef.NamespaceName, typeDefName);
                }

                _lastTypeDef     = td;
                _lastTypeDefName = typeDefName;
            }

            pchTypeDef = (uint)typeDefName.Length;
            if (pchTypeDef >= cchTypeDef)
            {
                pchTypeDef = cchTypeDef - 1;
            }

            char *pointerTypeDef = (char *)stringTypeDef.ToPointer();

            for (int i = 0; i < pchTypeDef; i++)
            {
                *(pointerTypeDef + i) = typeDefName[i];
            }

            *(pointerTypeDef + pchTypeDef) = (char)0;
            uint *pointerFlags = (uint *)pdwTypeDefFlags.ToPointer();

            *pointerFlags = _writer.GetTypeDefFlags(t.GetResolvedType(_writer.Context));
            return(0);
        }