<Compile Include="$(BclSourcesRoot)\System\SharedStatics.cs" />
<Compile Include="$(BclSourcesRoot)\System\Single.cs" />
<Compile Include="$(BclSourcesRoot)\System\StubHelpers.cs" />
- <Compile Include="$(BclSourcesRoot)\System\TimeSpan.cs" />
<Compile Include="$(BclSourcesRoot)\System\TimeZoneInfo.AdjustmentRule.cs" />
<Compile Include="$(BclSourcesRoot)\System\TimeZoneInfo.cs" />
<Compile Include="$(BclSourcesRoot)\System\TimeZoneInfo.StringSerializer.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\Globalization\BidiCategory.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Globalization\Calendar.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Globalization\CalendarData.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\CharUnicodeInfo.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\CharUnicodeInfoData.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\CompareInfo.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\CultureData.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\CultureInfo.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationMode.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Globalization\GregorianCalendar.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Globalization\GregorianCalendarHelper.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\IdnMapping.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\RegionInfo.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Globalization\TextElementEnumerator.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\TextInfo.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\TimeSpanFormat.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\TimeSpanParse.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Volatile.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandle.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\SpinLock.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Threading\SpinWait.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\LazyInitializer.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadLocal.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\SemaphoreSlim.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\FlagsAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\FormatException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\FormattableString.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\Calendar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarAlgorithmType.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarWeekRule.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendricalCalculationsHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\ChineseLunisolarCalendar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\DaylightTime.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\DigitShapes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\EastAsianLunisolarCalendar.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\GregorianCalendar.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\GregorianCalendarHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\GregorianCalendarTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HebrewCalendar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HebrewNumber.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\StringInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TaiwanCalendar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TaiwanLunisolarCalendar.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextElementEnumerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\ThaiBuddhistCalendar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TimeSpanStyles.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\UmAlQuraCalendar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF32Encoding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF7Encoding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF8Encoding.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\TimeSpan.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\ThreadAttributes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\AbandonedMutexException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ApartmentState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ReaderWriterLockSlim.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SemaphoreFullException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SendOrPostCallback.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Threading\SpinWait.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SynchronizationLockException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskCanceledException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\PathInternal.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Unix.cs" />
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
using System;
using System.Globalization;
using System.Diagnostics.Contracts;
-using System.Runtime.Serialization;
using System.Threading;
namespace System.Globalization
private static volatile Calendar s_defaultInstance;
- [OnDeserialized]
- private void OnDeserialized(StreamingContext ctx)
- {
- if (m_type < GregorianCalendarTypes.Localized ||
- m_type > GregorianCalendarTypes.TransliteratedFrench)
- {
- throw new SerializationException(
- String.Format(CultureInfo.CurrentCulture, SR.Serialization_MemberOutOfRange, "type", "GregorianCalendar"));
- }
- }
public override DateTime MinSupportedDateTime
{
using System;
using System.Diagnostics.Contracts;
-using System.Runtime.Serialization;
using System.Threading;
namespace System.Globalization
// be affected by the DateTime.MinValue;
internal int maxEraYear; // Max year value in this era. (== the year length of the era + 1)
- [OptionalField(VersionAdded = 4)]
internal String eraName; // The era name
- [OptionalField(VersionAdded = 4)]
internal String abbrevEraName; // Abbreviated Era Name
- [OptionalField(VersionAdded = 4)]
internal String englishEraName; // English era name
internal EraInfo(int era, int startYear, int startMonth, int startDay, int yearOffset, int minEraYear, int maxEraYear)
0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366
};
- [OptionalField(VersionAdded = 1)]
internal int m_maxYear = 9999;
- [OptionalField(VersionAdded = 1)]
internal int m_minYear;
internal Calendar m_Cal;
- [OptionalField(VersionAdded = 1)]
internal EraInfo[] m_EraInfo;
- [OptionalField(VersionAdded = 1)]
internal int[] m_eras = null;
using System.Collections;
using System.Diagnostics;
-using System.Runtime.Serialization;
namespace System.Globalization
{
private int _index;
private int _startIndex;
- [NonSerialized]
private int _strLen; // This is the length of the total string, counting from the beginning of string.
- [NonSerialized]
private int _currTextElementLen; // The current text element lenght after MoveNext() is called.
- [OptionalField(VersionAdded = 2)]
private UnicodeCategory _uc;
- [OptionalField(VersionAdded = 2)]
private int _charLen; // The next abstract char to look at after MoveNext() is called. It could be 1 or 2, depending on if it is a surrogate or not.
internal TextElementEnumerator(String str, int startIndex, int strLen)
Reset();
}
- // the following fields is defined to keep the compatibility with Everett.
- // don't change/remove the names/types of these fields.
- private int _endIndex;
- private int _nextTextElementLen;
-
- [OnDeserializing]
- private void OnDeserializing(StreamingContext ctx)
- {
- _charLen = -1;
- }
-
- [OnDeserialized]
- private void OnDeserialized(StreamingContext ctx)
- {
- _strLen = _endIndex + 1;
- _currTextElementLen = _nextTextElementLen;
-
- if (_charLen == -1)
- {
- _uc = CharUnicodeInfo.InternalGetUnicodeCategory(_str, _index, out _charLen);
- }
- }
-
- [OnSerializing]
- private void OnSerializing(StreamingContext ctx)
- {
- _endIndex = _strLen - 1;
- _nextTextElementLen = _currTextElementLen;
- }
-
public bool MoveNext()
{
if (_index >= _strLen)
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
-//
-//
// Central spin logic used across the entire code-base.
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-using System;
-using System.Runtime.ConstrainedExecution;
-using System.Threading;
using System.Diagnostics;
-using System.Diagnostics.Contracts;
-using System.Diagnostics.CodeAnalysis;
+using Internal.Runtime.Augments;
namespace System.Threading
{
/// <remarks>
/// <para>
/// <see cref="SpinWait"/> encapsulates common spinning logic. On single-processor machines, yields are
- /// always used instead of busy waits, and on computers with Intel processors employing Hyper-Threading
+ /// always used instead of busy waits, and on computers with Intel(R) processors employing Hyper-Threading
/// technology, it helps to prevent hardware thread starvation. SpinWait encapsulates a good mixture of
/// spinning and true yielding.
/// </para>
internal const int SLEEP_1_EVERY_HOW_MANY_TIMES = 20; // After how many yields should we Sleep(1)?
// The number of times we've spun already.
- private int m_count;
+ private int _count;
/// <summary>
/// Gets the number of times <see cref="SpinOnce"/> has been called on this instance.
/// </summary>
public int Count
{
- get { return m_count; }
+ get { return _count; }
}
/// <summary>
/// </remarks>
public bool NextSpinWillYield
{
- get { return m_count > YIELD_THRESHOLD || PlatformHelper.IsSingleProcessor; }
+ get { return _count > YIELD_THRESHOLD || PlatformHelper.IsSingleProcessor; }
}
/// <summary>
// remove the thread from the scheduler's queue for 10+ms, if the system is
// configured to use the (default) coarse-grained system timer.
//
- int yieldsSoFar = (m_count >= YIELD_THRESHOLD ? m_count - YIELD_THRESHOLD : m_count);
+
+ int yieldsSoFar = (_count >= YIELD_THRESHOLD ? _count - YIELD_THRESHOLD : _count);
if ((yieldsSoFar % SLEEP_1_EVERY_HOW_MANY_TIMES) == (SLEEP_1_EVERY_HOW_MANY_TIMES - 1))
{
- Thread.Sleep(1);
+ RuntimeThread.Sleep(1);
}
else if ((yieldsSoFar % SLEEP_0_EVERY_HOW_MANY_TIMES) == (SLEEP_0_EVERY_HOW_MANY_TIMES - 1))
{
- Thread.Sleep(0);
+ RuntimeThread.Sleep(0);
}
else
{
- Thread.Yield();
+ RuntimeThread.Yield();
}
}
else
// number of spins we are willing to tolerate to reduce delay to the caller,
// since we expect most callers will eventually block anyway.
//
- Thread.SpinWait(4 << m_count);
+ RuntimeThread.SpinWait(4 << _count);
}
// Finally, increment our spin counter.
- m_count = (m_count == int.MaxValue ? YIELD_THRESHOLD : m_count + 1);
+ _count = (_count == int.MaxValue ? YIELD_THRESHOLD : _count + 1);
}
/// <summary>
/// </remarks>
public void Reset()
{
- m_count = 0;
+ _count = 0;
}
#region Static Methods
return true;
}
#endregion
-
}
-
/// <summary>
/// A helper class to get the number of processors, it updates the numbers of processors every sampling interval.
/// </summary>
/// <summary>
/// Gets the number of available processors
/// </summary>
- [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")]
internal static int ProcessorCount
{
get
using System;
using System.Runtime;
using System.Runtime.CompilerServices;
-using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Globalization;
// an appropriate custom ILMarshaler to keep WInRT interop scenarios enabled.
//
[Serializable]
- public struct TimeSpan : IComparable
- , IComparable<TimeSpan>, IEquatable<TimeSpan>, IFormattable
+ public struct TimeSpan : IComparable, IComparable<TimeSpan>, IEquatable<TimeSpan>, IFormattable
{
public const long TicksPerMillisecond = 10000;
private const double MillisecondsPerTick = 1.0 / TicksPerMillisecond;
// method for some arithmetic operations.
internal long _ticks; // Do not rename (binary serialization)
- //public TimeSpan() {
- // _ticks = 0;
- //}
-
public TimeSpan(long ticks)
{
this._ticks = ticks;
// See System.Globalization.TimeSpanParse and System.Globalization.TimeSpanFormat
#region ParseAndFormat
+ private static void ValidateStyles(TimeSpanStyles style, String parameterName)
+ {
+ if (style != TimeSpanStyles.None && style != TimeSpanStyles.AssumeNegative)
+ throw new ArgumentException(SR.Argument_InvalidTimeSpanStyles, parameterName);
+ }
public static TimeSpan Parse(String s)
{
/* Constructs a TimeSpan from a string. Leading and trailing white space characters are allowed. */
}
public static TimeSpan ParseExact(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles)
{
- TimeSpanParse.ValidateStyles(styles, nameof(styles));
+ ValidateStyles(styles, nameof(styles));
return TimeSpanParse.ParseExact(input, format, formatProvider, styles);
}
public static TimeSpan ParseExact(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles)
{
- TimeSpanParse.ValidateStyles(styles, nameof(styles));
+ ValidateStyles(styles, nameof(styles));
return TimeSpanParse.ParseExactMultiple(input, formats, formatProvider, styles);
}
public static Boolean TryParse(String s, out TimeSpan result)
}
public static Boolean TryParseExact(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
{
- TimeSpanParse.ValidateStyles(styles, nameof(styles));
+ ValidateStyles(styles, nameof(styles));
return TimeSpanParse.TryParseExact(input, format, formatProvider, styles, out result);
}
public static Boolean TryParseExact(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
{
- TimeSpanParse.ValidateStyles(styles, nameof(styles));
+ ValidateStyles(styles, nameof(styles));
return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, styles, out result);
}
public override String ToString()
// Using floating-point arithmetic directly means that infinities can be returned, which is reasonable
// if we consider TimeSpan.FromHours(1) / TimeSpan.Zero asks how many zero-second intervals there are in
- // an hour for which ∞ is the mathematic correct answer. Having TimeSpan.Zero / TimeSpan.Zero return NaN
+ // an hour for which infinity is the mathematic correct answer. Having TimeSpan.Zero / TimeSpan.Zero return NaN
// is perhaps less useful, but no less useful than an exception.
public static double operator /(TimeSpan t1, TimeSpan t2) => t1.Ticks / (double)t2.Ticks;
internal static class TimeSpanParse
{
// ---- SECTION: members for internal support ---------*
- internal static void ValidateStyles(TimeSpanStyles style, String parameterName)
- {
- if (style != TimeSpanStyles.None && style != TimeSpanStyles.AssumeNegative)
- throw new ArgumentException(SR.Argument_InvalidTimeSpanStyles, parameterName);
- }
-
internal const int unlimitedDigits = -1;
internal const int maxFractionDigits = 7;