Ejemplo n.º 1
0
        public IntPtrConstructorMethodInvoker(MetadataReader reader, MethodHandle methodHandle)
        {
            // Since we control the definition of System.IntPtr, we only do enough analysis of the signature to disambiguate the constructors we support.
            _id = IntPtrConstructorId.None;
            Method method = methodHandle.GetMethod(reader);

            ParameterTypeSignatureHandle[] parameterTypeSignatureHandles = method.Signature.GetMethodSignature(reader).Parameters.ToArray();
            if (parameterTypeSignatureHandles.Length == 1)
            {
                ParameterTypeSignature parameterTypeSignature = parameterTypeSignatureHandles[0].GetParameterTypeSignature(reader);

                // If any parameter is a pointer type, bail as we don't support Invokes on pointers.
                if (parameterTypeSignature.Type.HandleType != HandleType.TypeDefinition)
                {
                    throw new PlatformNotSupportedException(SR.PlatformNotSupported_PointerArguments);
                }

                TypeDefinition typeDefinition = parameterTypeSignature.Type.ToTypeDefinitionHandle(reader).GetTypeDefinition(reader);
                String         name           = typeDefinition.Name.GetString(reader);
                switch (name)
                {
                case "Int32":
                    _id = IntPtrConstructorId.Int32;
                    break;

                case "Int64":
                    _id = IntPtrConstructorId.Int64;
                    break;

                case "UInt32":
                    _id = IntPtrConstructorId.UInt32;
                    break;

                case "UInt64":
                    _id = IntPtrConstructorId.UInt64;
                    break;

                default:
                    break;
                }
            }
        }
        public StringConstructorMethodInvoker(MetadataReader reader, MethodHandle methodHandle)
        {
            // Since we control the definition of System.String, we only do enough analysis of the signature to disambiguate the constructors we support.
            _id = StringConstructorId.None;
            Method method         = methodHandle.GetMethod(reader);
            int    parameterCount = 0;

            foreach (ParameterTypeSignatureHandle parameterTypeSignatureHandle in method.Signature.GetMethodSignature(reader).Parameters)
            {
                ParameterTypeSignature parameterTypeSignature = parameterTypeSignatureHandle.GetParameterTypeSignature(reader);

                // If any parameter is a pointer type, bail as we don't support Invokes on pointers.
                if (parameterTypeSignature.Type.HandleType == HandleType.TypeSpecification)
                {
                    TypeSpecification typeSpecification = parameterTypeSignature.Type.ToTypeSpecificationHandle(reader).GetTypeSpecification(reader);
                    if (typeSpecification.Signature.HandleType == HandleType.PointerSignature)
                    {
                        return;
                    }
                }
                parameterCount++;
            }

            switch (parameterCount)
            {
            case 1:
                _id = StringConstructorId.CharArray;
                break;

            case 2:
                _id = StringConstructorId.Char_Int;
                break;

            case 3:
                _id = StringConstructorId.CharArray_Int_Int;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
 private void InitializeParameterTypeSignature(Cts.TypeDesc entity, ParameterTypeSignature record)
 {
     // TODO: CustomModifiers
     record.Type = HandleType(entity);
 }