private NamedTypeSymbol TransformNamedType(NamedTypeSymbol type)
        {
            int index = Increment();

            if (!type.IsGenericType)
            {
                return(_transformFlags[index] ? TransformTypeDefinition(type) : type);
            }

            var allTypeArguments = ArrayBuilder <TypeWithAnnotations> .GetInstance();

            type.GetAllTypeArgumentsNoUseSiteDiagnostics(allTypeArguments);

            bool haveChanges = false;

            for (int i = 0; i < allTypeArguments.Count; i++)
            {
                TypeWithAnnotations oldTypeArgument = allTypeArguments[i];
                TypeWithAnnotations newTypeArgument = TransformTypeWithAnnotations(oldTypeArgument);
                if (!oldTypeArgument.IsSameAs(newTypeArgument))
                {
                    allTypeArguments[i] = newTypeArgument;
                    haveChanges         = true;
                }
            }

            NamedTypeSymbol result = haveChanges ? type.WithTypeArguments(allTypeArguments.ToImmutable()) : type;

            allTypeArguments.Free();
            return(result);
        }
Пример #2
0
        private NamedTypeSymbol TransformNamedType(NamedTypeSymbol type)
        {
            if (!type.IsGenericType)
            {
                switch (type.SpecialType)
                {
                case SpecialType.System_IntPtr:
                case SpecialType.System_UIntPtr:
                    if (_index >= _transformFlags.Length)
                    {
                        throw new UnsupportedSignatureContent();
                    }
                    return(_transformFlags[_index++] ? type.AsNativeInteger() : type);
                }
            }

            var allTypeArguments = ArrayBuilder <TypeWithAnnotations> .GetInstance();

            type.GetAllTypeArgumentsNoUseSiteDiagnostics(allTypeArguments);

            bool haveChanges = false;

            for (int i = 0; i < allTypeArguments.Count; i++)
            {
                TypeWithAnnotations oldTypeArgument = allTypeArguments[i];
                TypeWithAnnotations newTypeArgument = TransformTypeWithAnnotations(oldTypeArgument);
                if (!oldTypeArgument.IsSameAs(newTypeArgument))
                {
                    allTypeArguments[i] = newTypeArgument;
                    haveChanges         = true;
                }
            }

            NamedTypeSymbol result = haveChanges ? type.WithTypeArguments(allTypeArguments.ToImmutable()) : type;

            allTypeArguments.Free();
            return(result);
        }