Move files to shared CoreLib partition (dotnet/coreclr#12694)
authorJan Kotas <jkotas@microsoft.com>
Sun, 9 Jul 2017 06:46:00 +0000 (08:46 +0200)
committerGitHub <noreply@github.com>
Sun, 9 Jul 2017 06:46:00 +0000 (08:46 +0200)
Commit migrated from https://github.com/dotnet/coreclr/commit/fa5544c2b0589f1b1811dbfaf6f227327c4757fc

src/coreclr/src/mscorlib/System.Private.CoreLib.csproj
src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/coreclr/src/mscorlib/shared/System/Globalization/Calendar.cs [moved from src/coreclr/src/mscorlib/src/System/Globalization/Calendar.cs with 100% similarity]
src/coreclr/src/mscorlib/shared/System/Globalization/CalendarData.cs [moved from src/coreclr/src/mscorlib/src/System/Globalization/CalendarData.cs with 100% similarity]
src/coreclr/src/mscorlib/shared/System/Globalization/GregorianCalendar.cs [moved from src/coreclr/src/mscorlib/src/System/Globalization/GregorianCalendar.cs with 97% similarity]
src/coreclr/src/mscorlib/shared/System/Globalization/GregorianCalendarHelper.cs [moved from src/coreclr/src/mscorlib/src/System/Globalization/GregorianCalendarHelper.cs with 98% similarity]
src/coreclr/src/mscorlib/shared/System/Globalization/TextElementEnumerator.cs [moved from src/coreclr/src/mscorlib/src/System/Globalization/TextElementEnumerator.cs with 77% similarity]
src/coreclr/src/mscorlib/shared/System/Threading/SpinWait.cs [moved from src/coreclr/src/mscorlib/src/System/Threading/SpinWait.cs with 94% similarity]
src/coreclr/src/mscorlib/shared/System/TimeSpan.cs [moved from src/coreclr/src/mscorlib/src/System/TimeSpan.cs with 96% similarity]
src/coreclr/src/mscorlib/src/System/Globalization/TimeSpanParse.cs

index 062409f..9973e2b 100644 (file)
     <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" />
index 4610540..96e9888 100644 (file)
@@ -88,7 +88,9 @@
     <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>
@@ -5,7 +5,6 @@
 using System;
 using System.Globalization;
 using System.Diagnostics.Contracts;
-using System.Runtime.Serialization;
 using System.Threading;
 
 namespace System.Globalization
@@ -41,16 +40,6 @@ 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
         {
@@ -4,7 +4,6 @@
 
 using System;
 using System.Diagnostics.Contracts;
-using System.Runtime.Serialization;
 using System.Threading;
 
 namespace System.Globalization
@@ -21,11 +20,8 @@ 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)
@@ -111,15 +107,11 @@ namespace System.Globalization
             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;
 
 
@@ -12,7 +12,6 @@
 
 using System.Collections;
 using System.Diagnostics;
-using System.Runtime.Serialization;
 
 namespace System.Globalization
 {
@@ -26,16 +25,12 @@ 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)
@@ -49,36 +44,6 @@ namespace System.Globalization
             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)
@@ -4,18 +4,12 @@
 
 // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
 //
-//
-//
 // 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
 {
@@ -51,7 +45,7 @@ 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>
@@ -80,14 +74,14 @@ namespace System.Threading
         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>
@@ -102,7 +96,7 @@ namespace System.Threading
         /// </remarks>
         public bool NextSpinWillYield
         {
-            get { return m_count > YIELD_THRESHOLD || PlatformHelper.IsSingleProcessor; }
+            get { return _count > YIELD_THRESHOLD || PlatformHelper.IsSingleProcessor; }
         }
 
         /// <summary>
@@ -130,19 +124,20 @@ namespace System.Threading
                 // 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
@@ -158,11 +153,11 @@ namespace System.Threading
                 // 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>
@@ -175,7 +170,7 @@ namespace System.Threading
         /// </remarks>
         public void Reset()
         {
-            m_count = 0;
+            _count = 0;
         }
 
         #region Static Methods
@@ -268,10 +263,8 @@ namespace System.Threading
             return true;
         }
         #endregion
-
     }
 
-
     /// <summary>
     /// A helper class to get the number of processors, it updates the numbers of processors every sampling interval.
     /// </summary>
@@ -284,7 +277,6 @@ namespace System.Threading
         /// <summary>
         /// Gets the number of available processors
         /// </summary>
-        [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")]
         internal static int ProcessorCount
         {
             get
@@ -6,7 +6,6 @@ using System.Text;
 using System;
 using System.Runtime;
 using System.Runtime.CompilerServices;
-using System.Runtime.Versioning;
 using System.Diagnostics.Contracts;
 using System.Globalization;
 
@@ -30,8 +29,7 @@ namespace System
     // 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;
@@ -70,10 +68,6 @@ namespace System
         // method for some arithmetic operations.
         internal long _ticks; // Do not rename (binary serialization)
 
-        //public TimeSpan() {
-        //    _ticks = 0;
-        //}
-
         public TimeSpan(long ticks)
         {
             this._ticks = ticks;
@@ -315,6 +309,11 @@ namespace System
 
         // 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. */
@@ -334,12 +333,12 @@ namespace System
         }
         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)
@@ -360,12 +359,12 @@ namespace System
         }
         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()
@@ -442,7 +441,7 @@ namespace System
 
         // 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;
 
index a29e6c2..bcfb2da 100644 (file)
@@ -62,12 +62,6 @@ namespace System.Globalization
     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;