summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Text/UTF7Encoding.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Text/UTF7Encoding.cs')
-rw-r--r--src/mscorlib/src/System/Text/UTF7Encoding.cs55
1 files changed, 22 insertions, 33 deletions
diff --git a/src/mscorlib/src/System/Text/UTF7Encoding.cs b/src/mscorlib/src/System/Text/UTF7Encoding.cs
index 654fb8b80f..624ca735f6 100644
--- a/src/mscorlib/src/System/Text/UTF7Encoding.cs
+++ b/src/mscorlib/src/System/Text/UTF7Encoding.cs
@@ -11,6 +11,7 @@ namespace System.Text
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
@@ -175,7 +176,6 @@ namespace System.Text
return EncodingForwarder.GetByteCount(this, s);
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetByteCount(char* chars, int count)
@@ -205,7 +205,6 @@ namespace System.Text
return EncodingForwarder.GetBytes(this, chars, charIndex, charCount, bytes, byteIndex);
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
@@ -221,7 +220,6 @@ namespace System.Text
return EncodingForwarder.GetCharCount(this, bytes, index, count);
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public override unsafe int GetCharCount(byte* bytes, int count)
@@ -235,7 +233,6 @@ namespace System.Text
return EncodingForwarder.GetChars(this, bytes, byteIndex, byteCount, chars, charIndex);
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
@@ -254,23 +251,21 @@ namespace System.Text
// End of overridden methods which use EncodingForwarder
- [System.Security.SecurityCritical] // auto-generated
internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS baseEncoder)
{
- Contract.Assert(chars!=null, "[UTF7Encoding.GetByteCount]chars!=null");
- Contract.Assert(count >=0, "[UTF7Encoding.GetByteCount]count >=0");
+ Debug.Assert(chars!=null, "[UTF7Encoding.GetByteCount]chars!=null");
+ Debug.Assert(count >=0, "[UTF7Encoding.GetByteCount]count >=0");
// Just call GetBytes with bytes == null
return GetBytes(chars, count, null, 0, baseEncoder);
}
- [System.Security.SecurityCritical] // auto-generated
internal override unsafe int GetBytes(char* chars, int charCount,
byte* bytes, int byteCount, EncoderNLS baseEncoder)
{
- Contract.Assert(byteCount >=0, "[UTF7Encoding.GetBytes]byteCount >=0");
- Contract.Assert(chars!=null, "[UTF7Encoding.GetBytes]chars!=null");
- Contract.Assert(charCount >=0, "[UTF7Encoding.GetBytes]charCount >=0");
+ Debug.Assert(byteCount >=0, "[UTF7Encoding.GetBytes]byteCount >=0");
+ Debug.Assert(chars!=null, "[UTF7Encoding.GetBytes]chars!=null");
+ Debug.Assert(charCount >=0, "[UTF7Encoding.GetBytes]charCount >=0");
// Get encoder info
UTF7Encoding.Encoder encoder = (UTF7Encoding.Encoder)baseEncoder;
@@ -405,23 +400,21 @@ namespace System.Text
return buffer.Count;
}
- [System.Security.SecurityCritical] // auto-generated
internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder)
{
- Contract.Assert(count >=0, "[UTF7Encoding.GetCharCount]count >=0");
- Contract.Assert(bytes!=null, "[UTF7Encoding.GetCharCount]bytes!=null");
+ Debug.Assert(count >=0, "[UTF7Encoding.GetCharCount]count >=0");
+ Debug.Assert(bytes!=null, "[UTF7Encoding.GetCharCount]bytes!=null");
// Just call GetChars with null char* to do counting
return GetChars(bytes, count, null, 0, baseDecoder);
}
- [System.Security.SecurityCritical] // auto-generated
internal override unsafe int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, DecoderNLS baseDecoder)
{
- Contract.Assert(byteCount >=0, "[UTF7Encoding.GetChars]byteCount >=0");
- Contract.Assert(bytes!=null, "[UTF7Encoding.GetChars]bytes!=null");
- Contract.Assert(charCount >=0, "[UTF7Encoding.GetChars]charCount >=0");
+ Debug.Assert(byteCount >=0, "[UTF7Encoding.GetChars]byteCount >=0");
+ Debug.Assert(bytes!=null, "[UTF7Encoding.GetChars]bytes!=null");
+ Debug.Assert(charCount >=0, "[UTF7Encoding.GetChars]charCount >=0");
// Might use a decoder
UTF7Encoding.Decoder decoder = (UTF7Encoding.Decoder) baseDecoder;
@@ -440,7 +433,7 @@ namespace System.Text
bitCount = decoder.bitCount;
firstByte = decoder.firstByte;
- Contract.Assert(firstByte == false || decoder.bitCount <= 0,
+ Debug.Assert(firstByte == false || decoder.bitCount <= 0,
"[UTF7Encoding.GetChars]If remembered bits, then first byte flag shouldn't be set");
}
@@ -599,7 +592,7 @@ namespace System.Text
public override int GetMaxByteCount(int charCount)
{
if (charCount < 0)
- throw new ArgumentOutOfRangeException("charCount",
+ throw new ArgumentOutOfRangeException(nameof(charCount),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -623,7 +616,7 @@ namespace System.Text
// check for overflow
if (byteCount > 0x7fffffff)
- throw new ArgumentOutOfRangeException("charCount", Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow"));
+ throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow"));
return (int)byteCount;
}
@@ -632,7 +625,7 @@ namespace System.Text
public override int GetMaxCharCount(int byteCount)
{
if (byteCount < 0)
- throw new ArgumentOutOfRangeException("byteCount",
+ throw new ArgumentOutOfRangeException(nameof(byteCount),
Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
@@ -663,7 +656,7 @@ namespace System.Text
internal Decoder(SerializationInfo info, StreamingContext context)
{
// Any info?
- if (info==null) throw new ArgumentNullException("info");
+ if (info==null) throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
// Get common info
@@ -674,11 +667,10 @@ namespace System.Text
}
// ISerializable implementation, get data for this object
- [System.Security.SecurityCritical] // auto-generated_required
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
// Any info?
- if (info==null) throw new ArgumentNullException("info");
+ if (info==null) throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
// Save Whidbey data
@@ -727,7 +719,7 @@ namespace System.Text
internal Encoder(SerializationInfo info, StreamingContext context)
{
// Any info?
- if (info==null) throw new ArgumentNullException("info");
+ if (info==null) throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
// Get common info
@@ -737,11 +729,10 @@ namespace System.Text
}
// ISerializable implementation, get data for this object
- [System.Security.SecurityCritical] // auto-generated_required
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
// Any info?
- if (info==null) throw new ArgumentNullException("info");
+ if (info==null) throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
// Save Whidbey data
@@ -825,8 +816,8 @@ namespace System.Text
public override bool Fallback(byte[] bytesUnknown, int index)
{
// We expect no previous fallback in our buffer
- Contract.Assert(iCount < 0, "[DecoderUTF7FallbackBuffer.Fallback] Can't have recursive fallbacks");
- Contract.Assert(bytesUnknown.Length == 1, "[DecoderUTF7FallbackBuffer.Fallback] Only possible fallback case should be 1 unknown byte");
+ Debug.Assert(iCount < 0, "[DecoderUTF7FallbackBuffer.Fallback] Can't have recursive fallbacks");
+ Debug.Assert(bytesUnknown.Length == 1, "[DecoderUTF7FallbackBuffer.Fallback] Only possible fallback case should be 1 unknown byte");
// Go ahead and get our fallback
cFallback = (char)bytesUnknown[0];
@@ -872,7 +863,6 @@ namespace System.Text
}
// Clear the buffer
- [System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe void Reset()
{
iCount = -1;
@@ -880,13 +870,12 @@ namespace System.Text
}
// This version just counts the fallback and doesn't actually copy anything.
- [System.Security.SecurityCritical] // auto-generated
internal unsafe override int InternalFallback(byte[] bytes, byte* pBytes)
// Right now this has both bytes and bytes[], since we might have extra bytes, hence the
// array, and we might need the index, hence the byte*
{
// We expect no previous fallback in our buffer
- Contract.Assert(iCount < 0, "[DecoderUTF7FallbackBuffer.InternalFallback] Can't have recursive fallbacks");
+ Debug.Assert(iCount < 0, "[DecoderUTF7FallbackBuffer.InternalFallback] Can't have recursive fallbacks");
if (bytes.Length != 1)
{
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"));