// The calculation of hour/minute/second is moved to Calendar from GregorianCalendar,
// since most of the calendars (or all?) have the same way of calcuating hour/minute/second.
- public abstract partial class Calendar : ICloneable
+ public abstract class Calendar : ICloneable
{
// Number of 100ns (10E-7 second) ticks per time unit
internal const long TicksPerMillisecond = 10000;
private int _currentEraValue = -1;
- [OptionalField(VersionAdded = 2)]
private bool _isReadOnly = false;
-#if CORECLR
- internal const CalendarId CAL_HEBREW = CalendarId.HEBREW;
- internal const CalendarId CAL_HIJRI = CalendarId.HIJRI;
- internal const CalendarId CAL_JAPAN = CalendarId.JAPAN;
- internal const CalendarId CAL_JULIAN = CalendarId.JULIAN;
- internal const CalendarId CAL_TAIWAN = CalendarId.TAIWAN;
- internal const CalendarId CAL_UMALQURA = CalendarId.UMALQURA;
- internal const CalendarId CAL_PERSIAN = CalendarId.PERSIAN;
-#endif
-
// The minimum supported DateTime range for the calendar.
public virtual DateTime MinSupportedDateTime
}
else
{
- char upperCaseCh = Char.ToUpper(ch, CultureInfo.InvariantCulture);
+ char upperCaseCh = Char.ToUpperInvariant(ch);
if (upperCaseCh >= 'A' && upperCaseCh <= 'F')
{
continue;
private static bool IsHexPrefix(String str, int i)
{
- if (str.Length > i + 1 && str[i] == '0' && (Char.ToLower(str[i + 1], CultureInfo.InvariantCulture) == 'x'))
+ if (str.Length > i + 1 && str[i] == '0' && (Char.ToLowerInvariant(str[i + 1]) == 'x'))
return true;
else
return false;
Contract.EndContractBlock();
int length = Math.Min(strA.Length, strB.Length);
- fixed (char* ap = &strA.m_firstChar) fixed (char* bp = &strB.m_firstChar)
+ fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
{
char* a = ap;
char* b = bp;
int length = strA.Length;
- fixed (char* ap = &strA.m_firstChar) fixed (char* bp = &strB.m_firstChar)
+ fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
{
char* a = ap;
char* b = bp;
Contract.EndContractBlock();
int length = strA.Length;
- fixed (char* ap = &strA.m_firstChar) fixed (char* bp = &strB.m_firstChar)
+ fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
{
char* a = ap;
char* b = bp;
int length = startsWith.Length;
- fixed (char* ap = &str.m_firstChar) fixed (char* bp = &startsWith.m_firstChar)
+ fixed (char* ap = &str._firstChar) fixed (char* bp = &startsWith._firstChar)
{
char* a = ap;
char* b = bp;
// NOTE: This may be subject to change if eliminating the check
// in the callers makes them small enough to be inlined by the JIT
- Debug.Assert(strA.m_firstChar == strB.m_firstChar,
+ Debug.Assert(strA._firstChar == strB._firstChar,
"For performance reasons, callers of this method should " +
"check/short-circuit beforehand if the first char is the same.");
int length = Math.Min(strA.Length, strB.Length);
- fixed (char* ap = &strA.m_firstChar) fixed (char* bp = &strB.m_firstChar)
+ fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
{
char* a = ap;
char* b = bp;
// Check if the second chars are different here
- // The reason we check if m_firstChar is different is because
+ // The reason we check if _firstChar is different is because
// it's the most common case and allows us to avoid a method call
// to here.
// The reason we check if the second char is different is because
case StringComparison.Ordinal:
// Most common case: first character is different.
// Returns false for empty strings.
- if (strA.m_firstChar != strB.m_firstChar)
+ if (strA._firstChar != strB._firstChar)
{
- return strA.m_firstChar - strB.m_firstChar;
+ return strA._firstChar - strB._firstChar;
}
return CompareOrdinalHelper(strA, strB);
// Most common case, first character is different.
// This will return false for empty strings.
- if (strA.m_firstChar != strB.m_firstChar)
+ if (strA._firstChar != strB._firstChar)
{
- return strA.m_firstChar - strB.m_firstChar;
+ return strA._firstChar - strB._firstChar;
}
return CompareOrdinalHelper(strA, strB);
{
unsafe
{
- fixed (char* src = &m_firstChar)
+ fixed (char* src = &_firstChar)
{
Debug.Assert(src[this.Length] == '\0', "src[this.Length] == '\\0'");
Debug.Assert(((int)src) % 4 == 0, "Managed string should start at 4 bytes boundary");
return CultureInfo.InvariantCulture.CompareInfo.IsPrefix(this, value, CompareOptions.IgnoreCase);
case StringComparison.Ordinal:
- if (this.Length < value.Length || m_firstChar != value.m_firstChar)
+ if (this.Length < value.Length || _firstChar != value._firstChar)
{
return false;
}
}
[Pure]
- public bool StartsWith(char value) => Length != 0 && m_firstChar == value;
+ public bool StartsWith(char value) => Length != 0 && _firstChar == value;
}
}
}
Contract.EndContractBlock();
- fixed (char* pDest = &dest.m_firstChar)
- fixed (char* pSrc = &src.m_firstChar)
+ fixed (char* pDest = &dest._firstChar)
+ fixed (char* pSrc = &src._firstChar)
{
wstrcpy(pDest + destPos, pSrc, src.Length);
}
String result = FastAllocateString(newLength);
unsafe
{
- fixed (char* srcThis = &m_firstChar)
+ fixed (char* srcThis = &_firstChar)
{
- fixed (char* srcInsert = &value.m_firstChar)
+ fixed (char* srcInsert = &value._firstChar)
{
- fixed (char* dst = &result.m_firstChar)
+ fixed (char* dst = &result._firstChar)
{
wstrcpy(dst, srcThis, startIndex);
wstrcpy(dst + startIndex, srcInsert, insertLength);
public unsafe static string Join(string separator, params object[] values)
{
separator = separator ?? string.Empty;
- fixed (char* pSeparator = &separator.m_firstChar)
+ fixed (char* pSeparator = &separator._firstChar)
{
// Defer argument validation to the internal function
return JoinCore(pSeparator, separator.Length, values);
public unsafe static string Join<T>(string separator, IEnumerable<T> values)
{
separator = separator ?? string.Empty;
- fixed (char* pSeparator = &separator.m_firstChar)
+ fixed (char* pSeparator = &separator._firstChar)
{
// Defer argument validation to the internal function
return JoinCore(pSeparator, separator.Length, values);
public unsafe static string Join(string separator, string[] value, int startIndex, int count)
{
separator = separator ?? string.Empty;
- fixed (char* pSeparator = &separator.m_firstChar)
+ fixed (char* pSeparator = &separator._firstChar)
{
// Defer argument validation to the internal function
return JoinCore(pSeparator, separator.Length, value, startIndex, count);
if (i < end - 1)
{
// Fill in the separator.
- fixed (char* pResult = &result.m_firstChar)
+ fixed (char* pResult = &result._firstChar)
{
// If we are called from the char-based overload, we will not
// want to call MemoryCopy each time we fill in the separator. So
String result = FastAllocateString(totalWidth);
unsafe
{
- fixed (char* dst = &result.m_firstChar)
+ fixed (char* dst = &result._firstChar)
{
for (int i = 0; i < count; i++)
dst[i] = paddingChar;
- fixed (char* src = &m_firstChar)
+ fixed (char* src = &_firstChar)
{
wstrcpy(dst + count, src, oldLength);
}
String result = FastAllocateString(totalWidth);
unsafe
{
- fixed (char* dst = &result.m_firstChar)
+ fixed (char* dst = &result._firstChar)
{
- fixed (char* src = &m_firstChar)
+ fixed (char* src = &_firstChar)
{
wstrcpy(dst, src, oldLength);
}
String result = FastAllocateString(newLength);
unsafe
{
- fixed (char* src = &m_firstChar)
+ fixed (char* src = &_firstChar)
{
- fixed (char* dst = &result.m_firstChar)
+ fixed (char* dst = &result._firstChar)
{
wstrcpy(dst, src, startIndex);
wstrcpy(dst + startIndex, src + startIndex + count, newLength - startIndex);
{
int remainingLength = Length;
- fixed (char* pChars = &m_firstChar)
+ fixed (char* pChars = &_firstChar)
{
char* pSrc = pChars;
String result = FastAllocateString(Length);
- fixed (char* pChars = &m_firstChar)
+ fixed (char* pChars = &_firstChar)
{
- fixed (char* pResult = &result.m_firstChar)
+ fixed (char* pResult = &result._firstChar)
{
int copyLength = Length - remainingLength;
if (separators == null || separatorsLength == 0)
{
- fixed (char* pwzChars = &m_firstChar)
+ fixed (char* pwzChars = &_firstChar)
{
//If they passed null or an empty string, look for whitespace.
for (int i = 0; i < Length && foundCount < sepList.Length; i++)
{
int sepListCount = sepList.Length;
//If they passed in a string of chars, actually look for those chars.
- fixed (char* pwzChars = &m_firstChar)
+ fixed (char* pwzChars = &_firstChar)
{
for (int i = 0; i < Length && foundCount < sepListCount; i++)
{
int sepListCount = sepList.Length;
int currentSepLength = separator.Length;
- fixed (char* pwzChars = &m_firstChar)
+ fixed (char* pwzChars = &_firstChar)
{
for (int i = 0; i < Length && foundCount < sepListCount; i++)
{
int sepListCount = sepList.Length;
int sepCount = separators.Length;
- fixed (char* pwzChars = &m_firstChar)
+ fixed (char* pwzChars = &_firstChar)
{
for (int i = 0; i < Length && foundCount < sepListCount; i++)
{
String result = FastAllocateString(length);
- fixed (char* dest = &result.m_firstChar)
- fixed (char* src = &m_firstChar)
+ fixed (char* dest = &result._firstChar)
+ fixed (char* src = &_firstChar)
{
wstrcpy(dest, src + startIndex, length);
}
if (count < 0 || count > Length - startIndex)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
- fixed (char* pChars = &m_firstChar)
+ fixed (char* pChars = &_firstChar)
{
char* pCh = pChars + startIndex;
if (count < 0 || count - 1 > startIndex)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
- fixed (char* pChars = &m_firstChar)
+ fixed (char* pChars = &_firstChar)
{
char* pCh = pChars + startIndex;
// For empty strings, this will be '\0' since
// strings are both null-terminated and length prefixed
- [NonSerialized] private char m_firstChar;
+ [NonSerialized] private char _firstChar;
// The Empty constant holds the empty string value. It is initialized by the EE during startup.
// It is treated as intrinsic by the JIT as so the static constructor would never run.
//from native.
public static readonly String Empty;
- internal char FirstChar { get { return m_firstChar; } }
+ internal char FirstChar { get { return _firstChar; } }
//
// This is a helper method for the security team. They need to uppercase some strings (guaranteed to be less
// than 0x80) before security is fully initialized. Without security initialized, we can't grab resources (the nlp's)
//
int length = strIn.Length;
String strOut = FastAllocateString(length);
- fixed (char* inBuff = &strIn.m_firstChar, outBuff = &strOut.m_firstChar)
+ fixed (char* inBuff = &strIn._firstChar, outBuff = &strOut._firstChar)
{
for (int i = 0; i < length; i++)
{
// Note: fixed does not like empty arrays
if (count > 0)
{
- fixed (char* src = &m_firstChar)
+ fixed (char* src = &_firstChar)
fixed (char* dest = destination)
wstrcpy(dest + destinationIndex, src + sourceIndex, count);
}
if (length > 0)
{
char[] chars = new char[length];
- fixed (char* src = &m_firstChar) fixed (char* dest = chars)
+ fixed (char* src = &_firstChar) fixed (char* dest = chars)
{
wstrcpy(dest, src, length);
}
if (length > 0)
{
char[] chars = new char[length];
- fixed (char* src = &m_firstChar) fixed (char* dest = chars)
+ fixed (char* src = &_firstChar) fixed (char* dest = chars)
{
wstrcpy(dest, src + startIndex, length);
}
return String.Empty;
String s = FastAllocateString(stringLength);
- fixed (char* pTempChars = &s.m_firstChar)
+ fixed (char* pTempChars = &s._firstChar)
{
int doubleCheck = encoding.GetChars(bytes, byteLength, pTempChars, stringLength, null);
Debug.Assert(stringLength == doubleCheck,
}
// This is only intended to be used by char.ToString.
- // It is necessary to put the code in this class instead of Char, since m_firstChar is a private member.
- // Making m_firstChar internal would be dangerous since it would make it much easier to break String's immutability.
+ // It is necessary to put the code in this class instead of Char, since _firstChar is a private member.
+ // Making _firstChar internal would be dangerous since it would make it much easier to break String's immutability.
internal static string CreateFromChar(char c)
{
string result = FastAllocateString(1);
- result.m_firstChar = c;
+ result._firstChar = c;
return result;
}
unsafe internal int GetBytesFromEncoding(byte* pbNativeBuffer, int cbNativeBuffer, Encoding encoding)
{
// encoding == Encoding.UTF8
- fixed (char* pwzChar = &m_firstChar)
+ fixed (char* pwzChar = &_firstChar)
{
return encoding.GetBytes(pwzChar, m_stringLength, pbNativeBuffer, cbNativeBuffer);
}
uint flgs = (fBestFit ? 0 : WC_NO_BEST_FIT_CHARS);
uint DefaultCharUsed = 0;
- fixed (char* pwzChar = &m_firstChar)
+ fixed (char* pwzChar = &_firstChar)
{
nb = Win32Native.WideCharToMultiByte(
CP_ACP,
unsafe
{
- fixed (char* dest = &result.m_firstChar, source = value)
+ fixed (char* dest = &result._firstChar, source = value)
{
wstrcpy(dest, source, value.Length);
}
unsafe
{
- fixed (char* dest = &result.m_firstChar, source = value)
+ fixed (char* dest = &result._firstChar, source = value)
{
wstrcpy(dest, source + startIndex, length);
}
{
unsafe
{
- fixed (char* dest = &result.m_firstChar)
+ fixed (char* dest = &result._firstChar)
{
char* dmem = dest;
while (((uint)dmem & 3) != 0 && count > 0)
return String.Empty;
String result = FastAllocateString(count);
- fixed (char* dest = &result.m_firstChar)
+ fixed (char* dest = &result._firstChar)
wstrcpy(dest, ptr, count);
return result;
}
try
{
- fixed (char* dest = &result.m_firstChar)
+ fixed (char* dest = &result._firstChar)
wstrcpy(dest, pFrom, length);
return result;
}
String result = FastAllocateString(length);
- fixed (char* dest = &result.m_firstChar)
- fixed (char* src = &str.m_firstChar)
+ fixed (char* dest = &result._firstChar)
+ fixed (char* src = &str._firstChar)
{
wstrcpy(dest, src, length);
}
{
if (len == 0)
return;
- fixed (char* charPtr = &src.m_firstChar)
+ fixed (char* charPtr = &src._firstChar)
{
byte* srcPtr = (byte*)charPtr;
byte* dstPtr = (byte*)dest;
internal ref char GetRawStringData()
{
- return ref m_firstChar;
+ return ref _firstChar;
}
}
}
}
public String ToString(String format, IFormatProvider formatProvider)
{
- if (LegacyMode)
- {
- return TimeSpanFormat.Format(this, null, null);
- }
- else
- {
- return TimeSpanFormat.Format(this, format, formatProvider);
- }
+ return TimeSpanFormat.Format(this, format, formatProvider);
}
#endregion
{
return t1._ticks >= t2._ticks;
}
-
-
- //
- // In .NET Framework v1.0 - v3.5 System.TimeSpan did not implement IFormattable
- // The composite formatter ignores format specifiers on types that do not implement
- // IFormattable, so the following code would 'just work' by using TimeSpan.ToString()
- // under the hood:
- // String.Format("{0:_someRandomFormatString_}", myTimeSpan);
- //
- // In .NET Framework v4.0 System.TimeSpan implements IFormattable. This causes the
- // composite formatter to call TimeSpan.ToString(string format, FormatProvider provider)
- // and pass in "_someRandomFormatString_" for the format parameter. When the format
- // parameter is invalid a FormatException is thrown.
- //
- // The 'NetFx40_TimeSpanLegacyFormatMode' per-AppDomain configuration option and the 'TimeSpan_LegacyFormatMode'
- // process-wide configuration option allows applications to run with the v1.0 - v3.5 legacy behavior. When
- // either switch is specified the format parameter is ignored and the default output is returned.
- //
- // There are three ways to use the process-wide configuration option:
- //
- // 1) Config file (MyApp.exe.config)
- // <?xml version ="1.0"?>
- // <configuration>
- // <runtime>
- // <TimeSpan_LegacyFormatMode enabled="true"/>
- // </runtime>
- // </configuration>
- // 2) Environment variable
- // set COMPlus_TimeSpan_LegacyFormatMode=1
- // 3) RegistryKey
- // [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
- // "TimeSpan_LegacyFormatMode"=dword:00000001
- //
- private static bool GetLegacyFormatMode()
- {
- return false;
- }
-
- private static volatile bool _legacyConfigChecked;
- private static volatile bool _legacyMode;
-
- private static bool LegacyMode
- {
- get
- {
- if (!_legacyConfigChecked)
- {
- // no need to lock - idempotent
- _legacyMode = GetLegacyFormatMode();
- _legacyConfigChecked = true;
- }
- return _legacyMode;
- }
- }
}
}
DEFINE_FIELD(BITCONVERTER, ISLITTLEENDIAN, IsLittleEndian)
// Defined as element type alias
// DEFINE_CLASS(STRING, System, String)
-DEFINE_FIELD(STRING, M_FIRST_CHAR, m_firstChar)
+DEFINE_FIELD(STRING, M_FIRST_CHAR, _firstChar)
DEFINE_FIELD(STRING, EMPTY, Empty)
DEFINE_METHOD(STRING, CREATE_STRING, CreateString, SM_PtrSByt_Int_Int_Encoding_RetStr)
DEFINE_METHOD(STRING, CTOR_CHARPTR, .ctor, IM_PtrChar_RetVoid)