コード例 #1
0
        private static NamedTypeSymbol TransformTypeDefinition(NamedTypeSymbol type)
        {
            switch (type.SpecialType)
            {
            case SpecialType.System_IntPtr:
            case SpecialType.System_UIntPtr:
                return(type.AsNativeInteger());

            default:
                throw new UnsupportedSignatureContent();
            }
        }
コード例 #2
0
        private static NamedTypeSymbol TransformTypeDefinition(NamedTypeSymbol type)
        {
            switch (type.SpecialType)
            {
            case SpecialType.System_IntPtr:
            case SpecialType.System_UIntPtr:
                return(type.AsNativeInteger());

            default:
                throw new ArgumentException();
            }
        }
コード例 #3
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.IsNativeIntegerType) switch
             {
                 (false, true) => type.NativeIntegerUnderlyingType,
                 (true, false) => type.AsNativeInteger(),
                 _ => type,
             });
コード例 #4
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);
        }