Beispiel #1
0
        static void AppendTypeName(StringBuilder b, TypeSig type)
        {
            if (type == null)
            {
                // could happen when a TypeSpecification has no ElementType; e.g. function pointers in C++/CLI assemblies
                return;
            }
            if (type is GenericInstSig)
            {
                GenericInstSig giType = (GenericInstSig)type;
                AppendTypeNameWithArguments(b, giType.GenericType == null ? null : giType.GenericType.TypeDefOrRef, giType.GenericArguments);
                return;
            }
            ArraySigBase arrayType = type as ArraySigBase;

            if (arrayType != null)
            {
                AppendTypeName(b, arrayType.Next);
                b.Append('[');
                var lowerBounds = arrayType.GetLowerBounds();
                var sizes       = arrayType.GetSizes();
                for (int i = 0; i < arrayType.Rank; i++)
                {
                    if (i > 0)
                    {
                        b.Append(',');
                    }
                    if (i < lowerBounds.Count && i < sizes.Count)
                    {
                        b.Append(lowerBounds[i]);
                        b.Append(':');
                        b.Append(sizes[i] + lowerBounds[i] - 1);
                    }
                }
                b.Append(']');
                return;
            }
            ByRefSig refType = type as ByRefSig;

            if (refType != null)
            {
                AppendTypeName(b, refType.Next);
                b.Append('@');
                return;
            }
            PtrSig ptrType = type as PtrSig;

            if (ptrType != null)
            {
                AppendTypeName(b, ptrType.Next);
                b.Append('*');
                return;
            }
            GenericSig gp = type as GenericSig;

            if (gp != null)
            {
                b.Append('`');
                if (gp.IsMethodVar)
                {
                    b.Append('`');
                }
                b.Append(gp.Number);
            }
            else
            {
                var typeRef = type.ToTypeDefOrRef();
                if (typeRef.DeclaringType != null)
                {
                    AppendTypeName(b, typeRef.DeclaringType.ToTypeSig());
                    b.Append('.');
                    b.Append(typeRef.Name);
                }
                else
                {
                    b.Append(type.FullName);
                }
            }
        }
Beispiel #2
0
        static void AppendTypeName(StringBuilder b, TypeSig type)
        {
            if (type == null)
            {
                return;
            }
            if (type is GenericInstSig)
            {
                GenericInstSig giType = (GenericInstSig)type;
                AppendTypeNameWithArguments(b, giType.GenericType == null ? null : giType.GenericType.TypeDefOrRef, giType.GenericArguments);
                return;
            }
            ArraySigBase arrayType = type as ArraySigBase;

            if (arrayType != null)
            {
                AppendTypeName(b, arrayType.Next);
                b.Append('[');
                var lowerBounds = arrayType.GetLowerBounds();
                var sizes       = arrayType.GetSizes();
                for (int i = 0; i < arrayType.Rank; i++)
                {
                    if (i > 0)
                    {
                        b.Append(',');
                    }
                    if (i < lowerBounds.Count && i < sizes.Count)
                    {
                        b.Append(lowerBounds[i]);
                        b.Append(':');
                        b.Append(sizes[i] + lowerBounds[i] - 1);
                    }
                }
                b.Append(']');
                return;
            }
            ByRefSig refType = type as ByRefSig;

            if (refType != null)
            {
                AppendTypeName(b, refType.Next);
                b.Append('@');
                return;
            }
            PtrSig ptrType = type as PtrSig;

            if (ptrType != null)
            {
                AppendTypeName(b, ptrType.Next);
                b.Append('*');
                return;
            }
            GenericSig gp = type as GenericSig;

            if (gp != null)
            {
                b.Append('`');
                if (gp.IsMethodVar)
                {
                    b.Append('`');
                }
                b.Append(gp.Number);
            }
            else
            {
                var typeRef = type.ToTypeDefOrRef();
                if (typeRef.DeclaringType != null)
                {
                    AppendTypeName(b, typeRef.DeclaringType.ToTypeSig());
                    b.Append('.');
                    b.Append(typeRef.Name);
                }
                else
                {
                    FullNameCreator.FullNameSB(type, false, null, null, null, b);
                }
            }
        }