ThrowArgumentException_InvalidTypeWithPointersNotSupported() статический приватный Метод

static private ThrowArgumentException_InvalidTypeWithPointersNotSupported ( Type type ) : void
type Type
Результат void
Пример #1
0
        public static ReadOnlySpan <byte> AsBytes <T>(this ReadOnlySpan <T> source)
            where T : struct
        {
            if (!SpanHelpers.IsReferenceFree <T>())
            {
                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
            }

            int newLength = checked (source.Length * Unsafe.SizeOf <T>());

            return(new ReadOnlySpan <byte>(Unsafe.As <Pinnable <byte> >(source.Pinnable), source.ByteOffset, newLength));
        }
Пример #2
0
        public static Span <byte> AsBytes <T>(this Span <T> span)
            where T : struct
        {
            if (SpanHelpers.IsReferenceOrContainsReferences <T>())
            {
                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
            }

            int newLength = checked (span.Length * Unsafe.SizeOf <T>());

            return(new Span <byte>(Unsafe.As <Pinnable <byte> >(span.Pinnable), span.ByteOffset, newLength));
        }
Пример #3
0
        public unsafe ReadOnlySpan(void *pointer, int length)
        {
            if (SpanHelpers.IsReferenceOrContainsReferences <T>())
            {
                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
            }
            if (length < 0)
            {
                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
            }

            _length     = length;
            _pinnable   = null;
            _byteOffset = new IntPtr(pointer);
        }
Пример #4
0
        public static Span <TTo> NonPortableCast <TFrom, TTo>(this Span <TFrom> source)
            where TFrom : struct
            where TTo : struct
        {
            if (!SpanHelpers.IsReferenceFree <TFrom>())
            {
                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(TFrom));
            }

            if (!SpanHelpers.IsReferenceFree <TTo>())
            {
                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(TTo));
            }

            int newLength = checked ((int)((long)source.Length * Unsafe.SizeOf <TFrom>() / Unsafe.SizeOf <TTo>()));

            return(new Span <TTo>(Unsafe.As <Pinnable <TTo> >(source.Pinnable), source.ByteOffset, newLength));
        }