Simplify built-in types across corefx (dotnet/corefx#30656)

Commit migrated from https://github.com/dotnet/corefx/commit/e0ba7aa8026280ee3571179cc06431baf1dfaaac
This commit is contained in:
Stephen Toub authored and Jan Kotas committed 2018-06-25 16:54:41 -07:00
1 parent f8dd66c2b0
commit 2fb9f847fc
684 files changed
+4936 -4936

No files matched your search

@@ -43,7 +43,7 @@ namespace System.Text
// }
internal abstract class BaseCodePageEncoding : EncodingNLS, ISerializable
{
internal const String CODE_PAGE_DATA_FILE_NAME = "codepages.nlp";
internal const string CODE_PAGE_DATA_FILE_NAME = "codepages.nlp";
protected int dataTableCodePage;
@@ -146,7 +146,7 @@ namespace System.Text
// Initialize our global stuff
private static byte[] s_codePagesDataHeader = new byte[CODEPAGE_DATA_FILE_HEADER_SIZE];
protected static Stream s_codePagesEncodingDataStream = GetEncodingDataStream(CODE_PAGE_DATA_FILE_NAME);
protected static readonly Object s_streamLock = new Object(); // this lock used when reading from s_codePagesEncodingDataStream
protected static readonly object s_streamLock = new object(); // this lock used when reading from s_codePagesEncodingDataStream
// Real variables
protected byte[] m_codePageHeader = new byte[CODEPAGE_HEADER_SIZE];
@@ -156,7 +156,7 @@ namespace System.Text
// Safe handle wrapper around section map view
protected SafeAllocHHandle safeNativeMemoryHandle = null;
internal static Stream GetEncodingDataStream(String tableName)
internal static Stream GetEncodingDataStream(string tableName)
{
Debug.Assert(tableName != null, "table name can not be null");
@@ -212,14 +212,14 @@ namespace System.Text
}
// Private object for locking instead of locking on a public type for SQL reliability work.
private static Object s_InternalSyncObject;
private static Object InternalSyncObject
private static object s_InternalSyncObject;
private static object InternalSyncObject
{
get
{
if (s_InternalSyncObject == null)
{
Object o = new Object();
object o = new object();
Interlocked.CompareExchange<Object>(ref s_InternalSyncObject, o, null);
}
return s_InternalSyncObject;
@@ -539,7 +539,7 @@ namespace System.Text
// We may have a left over character from last time, try and process it.
if (charLeftOver > 0)
{
Debug.Assert(Char.IsHighSurrogate(charLeftOver), "[DBCSCodePageEncoding.GetByteCount]leftover character should be high surrogate");
Debug.Assert(char.IsHighSurrogate(charLeftOver), "[DBCSCodePageEncoding.GetByteCount]leftover character should be high surrogate");
Debug.Assert(encoder != null,
"[DBCSCodePageEncoding.GetByteCount]Expect to have encoder if we have a charLeftOver");
@@ -630,7 +630,7 @@ namespace System.Text
if (encoder != null)
{
charLeftOver = encoder.charLeftOver;
Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver),
Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver),
"[DBCSCodePageEncoding.GetBytes]leftover character should be high surrogate");
// Go ahead and get the fallback buffer (need leftover fallback if converting)
@@ -40,7 +40,7 @@ namespace System.Text
}
}
public override bool Equals(Object value)
public override bool Equals(object value)
{
InternalDecoderBestFitFallback that = value as InternalDecoderBestFitFallback;
if (that != null)
@@ -65,14 +65,14 @@ namespace System.Text
private InternalDecoderBestFitFallback _oFallback;
// Private object for locking instead of locking on a public type for SQL reliability work.
private static Object s_InternalSyncObject;
private static Object InternalSyncObject
private static object s_InternalSyncObject;
private static object InternalSyncObject
{
get
{
if (s_InternalSyncObject == null)
{
Object o = new Object();
object o = new object();
Interlocked.CompareExchange<Object>(ref s_InternalSyncObject, o, null);
}
return s_InternalSyncObject;
@@ -54,9 +54,9 @@ namespace System.Text
while ((ch = _fallbackBuffer.GetNextChar()) != 0)
{
// Make sure no mixed up surrogates
if (Char.IsSurrogate(ch))
if (char.IsSurrogate(ch))
{
if (Char.IsHighSurrogate(ch))
if (char.IsHighSurrogate(ch))
{
// High Surrogate
if (bHighSurrogate)
@@ -109,9 +109,9 @@ namespace System.Text
while ((ch = _fallbackBuffer.GetNextChar()) != 0)
{
// Make sure no mixed up surrogates
if (Char.IsSurrogate(ch))
if (char.IsSurrogate(ch))
{
if (Char.IsHighSurrogate(ch))
if (char.IsHighSurrogate(ch))
{
// High Surrogate
if (bHighSurrogate)
@@ -40,7 +40,7 @@ namespace System.Text
}
}
public override bool Equals(Object value)
public override bool Equals(object value)
{
InternalEncoderBestFitFallback that = value as InternalEncoderBestFitFallback;
if (that != null)
@@ -65,14 +65,14 @@ namespace System.Text
private int _iSize;
// Private object for locking instead of locking on a public type for SQL reliability work.
private static Object s_InternalSyncObject;
private static Object InternalSyncObject
private static object s_InternalSyncObject;
private static object InternalSyncObject
{
get
{
if (s_InternalSyncObject == null)
{
Object o = new Object();
object o = new object();
Interlocked.CompareExchange<Object>(ref s_InternalSyncObject, o, null);
}
return s_InternalSyncObject;
@@ -115,10 +115,10 @@ namespace System.Text
public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index)
{
// Double check input surrogate pair
if (!Char.IsHighSurrogate(charUnknownHigh))
if (!char.IsHighSurrogate(charUnknownHigh))
throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF));
if (!Char.IsLowSurrogate(charUnknownLow))
if (!char.IsLowSurrogate(charUnknownLow))
throw new ArgumentOutOfRangeException(nameof(charUnknownLow), SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF));
// If we had a buffer already we're being recursive, throw, it's probably at the suspect
@@ -76,7 +76,7 @@ namespace System.Text
int index = (int)(chars - charStart) - 1;
// See if it was a high surrogate
if (Char.IsHighSurrogate(ch))
if (char.IsHighSurrogate(ch))
{
// See if there's a low surrogate to go with it
if (chars >= charEnd)
@@ -99,11 +99,11 @@ namespace System.Text
{
// Might have a low surrogate
char cNext = *chars;
if (Char.IsLowSurrogate(cNext))
if (char.IsLowSurrogate(cNext))
{
// If already falling back then fail
if (bFallingBack && iRecursionCount++ > iMaxRecursion)
ThrowLastCharRecursive(Char.ConvertToUtf32(ch, cNext));
ThrowLastCharRecursive(char.ConvertToUtf32(ch, cNext));
// Next is a surrogate, add it as surrogate pair, and increment chars
chars++;
@@ -69,7 +69,7 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
public override unsafe int GetByteCount(String s)
public override unsafe int GetByteCount(string s)
{
// Validate input
if (s == null)
@@ -98,7 +98,7 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
public override unsafe int GetBytes(String s, int charIndex, int charCount,
public override unsafe int GetBytes(string s, int charIndex, int charCount,
byte[] bytes, int byteIndex)
{
if (s == null || bytes == null)
@@ -283,7 +283,7 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
public override unsafe String GetString(byte[] bytes, int index, int count)
public override unsafe string GetString(byte[] bytes, int index, int count)
{
// Validate Parameters
if (bytes == null)
@@ -296,7 +296,7 @@ namespace System.Text
throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);
// Avoid problems with empty input buffer
if (bytes.Length == 0) return String.Empty;
if (bytes.Length == 0) return string.Empty;
fixed (byte* pBytes = &bytes[0])
return GetString(pBytes + index, count);
@@ -357,7 +357,7 @@ namespace System.Text
throw new ArgumentException(SR.Format(SR.Argument_EncodingConversionOverflowChars, EncodingName, DecoderFallback.GetType()), "chars");
}
public override String EncodingName
public override string EncodingName
{
get
{
@@ -539,7 +539,7 @@ namespace System.Text
}
// Returns the IANA preferred name for this encoding
public override String WebName
public override string WebName
{
get
{
@@ -754,7 +754,7 @@ namespace System.Text
// names listed in s_encodingNames. The way mapping works is we binary search
// s_encodingNames using s_encodingNamesIndices until we find a match for a given name.
// The index of the entry in s_encodingNamesIndices will be the index of codepage in s_codePagesByName.
private static readonly UInt16[] s_codePagesByName = new UInt16[]
private static readonly ushort[] s_codePagesByName = new ushort[]
{
437, // 437
28596, // arabic
@@ -1127,7 +1127,7 @@ namespace System.Text
// given codepage. This is used to index WebNameIndices to get the start
// index of the web name in the string WebNames, and to index
// s_englishNameIndices to get the start of the English name in s_englishNames.
private static readonly UInt16[] s_mappedCodePages = new UInt16[]
private static readonly ushort[] s_mappedCodePages = new ushort[]
{
37, // ibm037
437, // ibm437
@@ -242,11 +242,11 @@ namespace System.Text
// Have to check for charLeftOver
if (charLeftOver != 0)
{
Debug.Assert(Char.IsHighSurrogate(charLeftOver),
Debug.Assert(char.IsHighSurrogate(charLeftOver),
"[GB18030Encoding.GetBytes] leftover character should be high surrogate, not 0x" + ((int)charLeftOver).ToString("X4", CultureInfo.InvariantCulture));
// If our next char isn't a low surrogate, then we need to do fallback.
if (!Char.IsLowSurrogate(ch))
if (!char.IsLowSurrogate(ch))
{
// No low surrogate, fallback high surrogate & try this one again
buffer.MovePrevious(false); // (Ignoring this character, don't throw)
@@ -293,12 +293,12 @@ namespace System.Text
break;
}
// See if its a surrogate pair
else if (Char.IsHighSurrogate(ch))
else if (char.IsHighSurrogate(ch))
{
// Remember it for next time
charLeftOver = ch;
}
else if (Char.IsLowSurrogate(ch))
else if (char.IsLowSurrogate(ch))
{
// Low surrogates should've been found already
if (!buffer.Fallback(ch))
@@ -385,7 +385,7 @@ namespace System.Text
Debug.Assert(((bLastVirama ? 1 : 0) + (bLastATR ? 1 : 0) +
(bLastDevenagariStressAbbr ? 1 : 0) +
((cLastCharForNextNukta > 0) ? 1 : 0)) == 1,
String.Format(CultureInfo.InvariantCulture,
string.Format(CultureInfo.InvariantCulture,
"[ISCIIEncoding.GetChars]Special cases require 1 and only 1 special case flag: LastATR {0} Dev. {1} Nukta {2}",
bLastATR, bLastDevenagariStressAbbr, cLastCharForNextNukta));
// If the last one was an ATR, then we'll have to do ATR stuff
@@ -613,7 +613,7 @@ namespace System.Text
// We must be the Devenagari special case for F0, B8 & F0, BF
Debug.Assert(currentCodePage == CodeDevanagari && b == DevenagariExt,
String.Format(CultureInfo.InvariantCulture,
string.Format(CultureInfo.InvariantCulture,
"[ISCIIEncoding.GetChars] Devenagari special case must {0} not {1} or in Devanagari code page {2} not {3}.",
DevenagariExt, b, CodeDevanagari, currentCodePage));
bLastDevenagariStressAbbr = bLastSpecial = true;
@@ -374,7 +374,7 @@ namespace System.Text
// We may have a left over character from last time, try and process it.
if (charLeftOver > 0)
{
Debug.Assert(Char.IsHighSurrogate(charLeftOver), "[ISO2022Encoding.GetBytesCP5022xJP]leftover character should be high surrogate");
Debug.Assert(char.IsHighSurrogate(charLeftOver), "[ISO2022Encoding.GetBytesCP5022xJP]leftover character should be high surrogate");
// It has to be a high surrogate, which we don't support, so it has to be a fallback
buffer.Fallback(charLeftOver);
@@ -615,7 +615,7 @@ namespace System.Text
// We may have a l left over character from last time, try and process it.
if (charLeftOver > 0)
{
Debug.Assert(Char.IsHighSurrogate(charLeftOver), "[ISO2022Encoding.GetBytesCP50225KR]leftover character should be high surrogate");
Debug.Assert(char.IsHighSurrogate(charLeftOver), "[ISO2022Encoding.GetBytesCP50225KR]leftover character should be high surrogate");
// It has to be a high surrogate, which we don't support, so it has to be a fallback
buffer.Fallback(charLeftOver);
@@ -761,7 +761,7 @@ namespace System.Text
// We may have a left over character from last time, try and process it.
if (charLeftOver > 0)
{
Debug.Assert(Char.IsHighSurrogate(charLeftOver), "[ISO2022Encoding.GetBytesCP52936]leftover character should be high surrogate");
Debug.Assert(char.IsHighSurrogate(charLeftOver), "[ISO2022Encoding.GetBytesCP52936]leftover character should be high surrogate");
// It has to be a high surrogate, which we don't support, so it has to be a fallback
buffer.Fallback(charLeftOver);
@@ -116,14 +116,14 @@ namespace System.Text
}
// Private object for locking instead of locking on a public type for SQL reliability work.
private static Object s_InternalSyncObject;
private static Object InternalSyncObject
private static object s_InternalSyncObject;
private static object InternalSyncObject
{
get
{
if (s_InternalSyncObject == null)
{
Object o = new Object();
object o = new object();
Interlocked.CompareExchange<Object>(ref s_InternalSyncObject, o, null);
}
return s_InternalSyncObject;
@@ -165,7 +165,7 @@ namespace System.Text
ushort byteTemp;
while ((byteTemp = *((ushort*)pData)) != 0)
{
Debug.Assert(arrayTemp[byteTemp] == UNKNOWN_CHAR, String.Format(CultureInfo.InvariantCulture,
Debug.Assert(arrayTemp[byteTemp] == UNKNOWN_CHAR, string.Format(CultureInfo.InvariantCulture,
"[SBCSCodePageEncoding::ReadBestFitTable] Expected unallocated byte (not 0x{2:X2}) for best fit byte at 0x{0:X2} for code page {1}",
byteTemp, CodePage, (int)arrayTemp[byteTemp]));
pData += 2;
@@ -267,7 +267,7 @@ namespace System.Text
// This won't work if it won't round trip.
Debug.Assert(arrayTemp[iBestFitCount - 1] != (char)0,
String.Format(CultureInfo.InvariantCulture,
string.Format(CultureInfo.InvariantCulture,
"[SBCSCodePageEncoding.ReadBestFitTable] No valid Unicode value {0:X4} for round trip bytes {1:X4}, encoding {2}",
(int)_mapBytesToUnicode[input], (int)input, CodePage));
}
@@ -304,7 +304,7 @@ namespace System.Text
if (encoder != null)
{
charLeftOver = encoder.charLeftOver;
Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver),
Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver),
"[SBCSCodePageEncoding.GetByteCount]leftover character should be high surrogate");
fallback = encoder.Fallback as EncoderReplacementFallback;
@@ -431,7 +431,7 @@ namespace System.Text
if (encoder != null)
{
charLeftOver = encoder.charLeftOver;
Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver),
Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver),
"[SBCSCodePageEncoding.GetBytes]leftover character should be high surrogate");
fallback = encoder.Fallback as EncoderReplacementFallback;