Ejemplo n.º 1
0
        // Methods that do no return (i.e. throw) are not inlined
        // https://github.com/dotnet/coreclr/pull/6103
        private static void ThrowInvalidArguments(string buffer, int offset, int length)
        {
            // Only have single throw in method so is marked as "does not return" and isn't inlined to caller
            throw GetInvalidArgumentsException();

            Exception GetInvalidArgumentsException()
            {
                if (buffer == null)
                {
                    return(ThrowHelper.GetArgumentNullException(ExceptionArgument.buffer));
                }

                if (offset < 0)
                {
                    return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.offset));
                }

                if (length < 0)
                {
                    return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.length));
                }

                return(ThrowHelper.GetArgumentException(ExceptionResource.Argument_InvalidOffsetLength));
            }
        }
Ejemplo n.º 2
0
        private static Exception GetInvalidArgumentException(string buffer, int offset, int length)
        {
            if (buffer == null)
            {
                return(ThrowHelper.GetArgumentNullException(ExceptionArgument.buffer));
            }

            if (offset < 0)
            {
                return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.offset));
            }

            if (length < 0)
            {
                return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.length));
            }

            return(ThrowHelper.GetArgumentException(ExceptionResource.Argument_InvalidOffsetLength));
        }