<PackageReference Include="System.Text.Encodings.Web" Version="10.0.0-preview.2.25163.2" />

ThrowHelper

static class ThrowHelper
using System.Diagnostics.CodeAnalysis; namespace System { internal static class ThrowHelper { [System.Diagnostics.CodeAnalysis.DoesNotReturn] internal static void ThrowArgumentOutOfRangeException() { throw new ArgumentOutOfRangeException(); } [System.Diagnostics.CodeAnalysis.DoesNotReturn] internal static void ThrowArgumentException_DestinationTooShort() { throw new ArgumentException(System.SR.Argument_DestinationTooShort, "destination"); } [System.Diagnostics.CodeAnalysis.DoesNotReturn] internal static void ThrowArgumentException_CannotExtractScalar(System.ExceptionArgument argument) { throw GetArgumentException(System.ExceptionResource.Argument_CannotExtractScalar, argument); } [System.Diagnostics.CodeAnalysis.DoesNotReturn] internal static void ThrowArgumentOutOfRange_IndexMustBeLessException() { throw GetArgumentOutOfRangeException(System.ExceptionArgument.index, System.ExceptionResource.ArgumentOutOfRange_IndexMustBeLess); } [System.Diagnostics.CodeAnalysis.DoesNotReturn] internal static void ThrowArgumentNullException(System.ExceptionArgument argument) { throw new ArgumentNullException(GetArgumentName(argument)); } [System.Diagnostics.CodeAnalysis.DoesNotReturn] internal static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument) { throw new ArgumentOutOfRangeException(GetArgumentName(argument)); } private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) { return new ArgumentOutOfRangeException(GetArgumentName(argument), GetResourceString(resource)); } private static ArgumentException GetArgumentException(System.ExceptionResource resource, System.ExceptionArgument argument) { return new ArgumentException(GetResourceString(resource), GetArgumentName(argument)); } private static string GetArgumentName(System.ExceptionArgument argument) { switch (argument) { case System.ExceptionArgument.ch: return "ch"; case System.ExceptionArgument.culture: return "culture"; case System.ExceptionArgument.index: return "index"; case System.ExceptionArgument.input: return "input"; case System.ExceptionArgument.value: return "value"; default: return ""; } } private static string GetResourceString(System.ExceptionResource resource) { switch (resource) { case System.ExceptionResource.ArgumentOutOfRange_IndexMustBeLess: return System.SR.ArgumentOutOfRange_IndexMustBeLess; case System.ExceptionResource.Argument_CannotExtractScalar: return System.SR.Argument_CannotExtractScalar; default: return ""; } } } }