summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Text/Decoder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Text/Decoder.cs')
-rw-r--r--src/mscorlib/src/System/Text/Decoder.cs32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/mscorlib/src/System/Text/Decoder.cs b/src/mscorlib/src/System/Text/Decoder.cs
index f794dc4dce..0ebbacddcf 100644
--- a/src/mscorlib/src/System/Text/Decoder.cs
+++ b/src/mscorlib/src/System/Text/Decoder.cs
@@ -7,6 +7,7 @@ namespace System.Text
using System.Runtime.Serialization;
using System.Text;
using System;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
// A Decoder is used to decode a sequence of blocks of bytes into a
// sequence of blocks of characters. Following instantiation of a decoder,
@@ -49,13 +50,13 @@ namespace System.Text
set
{
if (value == null)
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
Contract.EndContractBlock();
// Can't change fallback if buffer is wrong
if (m_fallbackBuffer != null && m_fallbackBuffer.Remaining > 0)
throw new ArgumentException(
- Environment.GetResourceString("Argument_FallbackBufferNotEmpty"), "value");
+ Environment.GetResourceString("Argument_FallbackBufferNotEmpty"), nameof(value));
m_fallback = value;
m_fallbackBuffer = null;
@@ -124,18 +125,17 @@ namespace System.Text
// We expect this to be the workhorse for NLS Encodings, but for existing
// ones we need a working (if slow) default implimentation)
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public virtual unsafe int GetCharCount(byte* bytes, int count, bool flush)
{
// Validate input parameters
if (bytes == null)
- throw new ArgumentNullException("bytes",
+ throw new ArgumentNullException(nameof(bytes),
Environment.GetResourceString("ArgumentNull_Array"));
if (count < 0)
- throw new ArgumentOutOfRangeException("count",
+ throw new ArgumentOutOfRangeException(nameof(count),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -189,7 +189,6 @@ namespace System.Text
// the char[] to our char* output buffer. If the result count was wrong, we
// could easily overflow our output buffer. Therefore we do an extra test
// when we copy the buffer so that we don't overflow charCount either.
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public virtual unsafe int GetChars(byte* bytes, int byteCount,
@@ -197,11 +196,11 @@ namespace System.Text
{
// Validate input parameters
if (chars == null || bytes == null)
- throw new ArgumentNullException(chars == null ? "chars" : "bytes",
+ throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes),
Environment.GetResourceString("ArgumentNull_Array"));
if (byteCount < 0 || charCount < 0)
- throw new ArgumentOutOfRangeException((byteCount<0 ? "byteCount" : "charCount"),
+ throw new ArgumentOutOfRangeException((byteCount<0 ? nameof(byteCount) : nameof(charCount)),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -218,7 +217,7 @@ namespace System.Text
// Do the work
int result = GetChars(arrByte, 0, byteCount, arrChar, 0, flush);
- Contract.Assert(result <= charCount, "Returned more chars than we have space for");
+ Debug.Assert(result <= charCount, "Returned more chars than we have space for");
// Copy the char array
// WARNING: We MUST make sure that we don't copy too many chars. We can't
@@ -256,23 +255,23 @@ namespace System.Text
{
// Validate parameters
if (bytes == null || chars == null)
- throw new ArgumentNullException((bytes == null ? "bytes" : "chars"),
+ throw new ArgumentNullException((bytes == null ? nameof(bytes) : nameof(chars)),
Environment.GetResourceString("ArgumentNull_Array"));
if (byteIndex < 0 || byteCount < 0)
- throw new ArgumentOutOfRangeException((byteIndex<0 ? "byteIndex" : "byteCount"),
+ throw new ArgumentOutOfRangeException((byteIndex<0 ? nameof(byteIndex) : nameof(byteCount)),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (charIndex < 0 || charCount < 0)
- throw new ArgumentOutOfRangeException((charIndex<0 ? "charIndex" : "charCount"),
+ throw new ArgumentOutOfRangeException((charIndex<0 ? nameof(charIndex) : nameof(charCount)),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (bytes.Length - byteIndex < byteCount)
- throw new ArgumentOutOfRangeException("bytes",
+ throw new ArgumentOutOfRangeException(nameof(bytes),
Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
if (chars.Length - charIndex < charCount)
- throw new ArgumentOutOfRangeException("chars",
+ throw new ArgumentOutOfRangeException(nameof(chars),
Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
Contract.EndContractBlock();
@@ -306,7 +305,6 @@ namespace System.Text
// Note that if all of the input bytes are not consumed, then we'll do a /2, which means
// that its likely that we didn't consume as many bytes as we could have. For some
// applications this could be slow. (Like trying to exactly fill an output buffer from a bigger stream)
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public virtual unsafe void Convert(byte* bytes, int byteCount,
@@ -315,11 +313,11 @@ namespace System.Text
{
// Validate input parameters
if (chars == null || bytes == null)
- throw new ArgumentNullException(chars == null ? "chars" : "bytes",
+ throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes),
Environment.GetResourceString("ArgumentNull_Array"));
if (byteCount < 0 || charCount < 0)
- throw new ArgumentOutOfRangeException((byteCount<0 ? "byteCount" : "charCount"),
+ throw new ArgumentOutOfRangeException((byteCount<0 ? nameof(byteCount) : nameof(charCount)),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();