<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\ConditionalWeakTable.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\AsyncMethodBuilder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\TaskAwaiter.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\YieldAwaitable.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\Runtime\Reliability\CriticalFinalizerObject.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\GcSettings.cs" />
</ItemGroup>
<ItemGroup>
- <Compile Include="$(BclSourcesRoot)\System\Collections\Comparer.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\CompatibleComparer.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\EmptyReadOnlyDictionaryInternal.cs" />
<Compile Include="$(BclSourcesRoot)\System\Collections\Hashtable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Char.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\CharEnumerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\CLSCompliantAttribute.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Comparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\DictionaryEntry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\Dictionary.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\ICollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\TypeForwardedToAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\UnsafeValueTypeAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ValueTaskAwaiter.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\YieldAwaitable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ConstrainedExecution\Cer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ConstrainedExecution\Consistency.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ConstrainedExecution\ReliabilityContractAttribute.cs" />
/*============================================================
**
-**
-**
-**
-**
** Purpose: Default IComparer implementation.
**
-**
===========================================================*/
using System.Globalization;
+using System.Runtime.Serialization;
namespace System.Collections
{
- internal sealed class Comparer : IComparer
+ [Serializable]
+ [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+ public sealed class Comparer : IComparer, ISerializable
{
- private CompareInfo m_compareInfo;
+ private CompareInfo _compareInfo;
+
public static readonly Comparer Default = new Comparer(CultureInfo.CurrentCulture);
public static readonly Comparer DefaultInvariant = new Comparer(CultureInfo.InvariantCulture);
- private Comparer()
- {
- m_compareInfo = null;
- }
-
public Comparer(CultureInfo culture)
{
if (culture == null)
- {
throw new ArgumentNullException(nameof(culture));
- }
- m_compareInfo = culture.CompareInfo;
+
+ _compareInfo = culture.CompareInfo;
+ }
+
+ private Comparer(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException(nameof(info));
+
+ _compareInfo = (CompareInfo)info.GetValue("CompareInfo", typeof(CompareInfo));
+ }
+
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException(nameof(info));
+
+ info.AddValue("CompareInfo", _compareInfo);
}
- // Compares two Objects by calling CompareTo. If a ==
- // b,0 is returned. If a implements
- // IComparable, a.CompareTo(b) is returned. If a
- // doesn't implement IComparable and b does,
- // -(b.CompareTo(a)) is returned, otherwise an
- // exception is thrown.
+ // Compares two Objects by calling CompareTo.
+ // If a == b, 0 is returned.
+ // If a implements IComparable, a.CompareTo(b) is returned.
+ // If a doesn't implement IComparable and b does, -(b.CompareTo(a)) is returned.
+ // Otherwise an exception is thrown.
//
public int Compare(Object a, Object b)
{
if (a == b) return 0;
if (a == null) return -1;
if (b == null) return 1;
- if (m_compareInfo != null)
- {
- String sa = a as String;
- String sb = b as String;
- if (sa != null && sb != null)
- return m_compareInfo.Compare(sa, sb);
- }
+
+ string sa = a as string;
+ string sb = b as string;
+ if (sa != null && sb != null)
+ return _compareInfo.Compare(sa, sb);
IComparable ia = a as IComparable;
if (ia != null)
// keeps the performance not affected till we hit collision threshold and then we switch to the comparer which is using
// randomized string hashing.
[Serializable] // Required for compatibility with .NET Core 2.0 as we exposed the NonRandomizedStringEqualityComparer inside the serialization blob
-#if CORECLR
- internal
-#else
+#if CORERT
public
+#else
+ internal
#endif
sealed class NonRandomizedStringEqualityComparer : EqualityComparer<string>, ISerializable
{
namespace System.Globalization
{
-#if CORECLR
- using StringStringDictionary = Dictionary<string, string>;
- using StringList = List<string>;
-#else
- using StringStringDictionary = LowLevelDictionary<string, string>;
- using StringList = LowLevelList<string>;
-#endif
-
//
// from LocaleEx.txt header
//
internal const String CJKSecondSuff = "\u79d2";
// The collection fo date words & postfix.
- internal StringList m_dateWords = new StringList();
+ internal List<string> m_dateWords = new List<string>();
// Hashtable for the known words.
- private static volatile StringStringDictionary s_knownWords;
+ private static volatile Dictionary<string, string> s_knownWords;
- static StringStringDictionary KnownWords
+ static Dictionary<string, string> KnownWords
{
get
{
if (s_knownWords == null)
{
- StringStringDictionary temp = new StringStringDictionary();
+ Dictionary<string, string> temp = new Dictionary<string, string>();
// Add known words into the hash table.
// Skip these special symbols.
{
if (m_dateWords == null)
{
- m_dateWords = new StringList();
+ m_dateWords = new List<string>();
}
if (formatPostfix == "MMMM")
{
if (m_dateWords == null)
{
// Create the date word array.
- m_dateWords = new StringList();
+ m_dateWords = new List<string>();
}
// Add the ignorable symbol into the ArrayList.
String temp = IgnorableSymbolChar + text;
}
}
}
-
private static Action OutputCorrelationEtwEvent(Action continuation)
{
+#if CORERT
+ // TODO
+ return continuation;
+#else
int continuationId = Task.NewId();
Task currentTask = Task.InternalCurrent;
// fire the correlation ETW event
EventSource.SetCurrentThreadActivityId(prevActivityId);
etwLog.TaskWaitContinuationComplete(((Task<int>)continuationIdTask).Result);
- }, Task.FromResult(continuationId)); // pass the ID in a task to avoid a closure
+ }, Task.FromResult(continuationId)); // pass the ID in a task to avoid a closure\
+#endif
}
/// <summary>WaitCallback that invokes the Action supplied as object state.</summary>
{
// Since CompareInfo's don't have any overrideable properties, get the CompareInfo from
// the Non-Overridden CultureInfo so that we only create one CompareInfo per culture
- CompareInfo temp = UseUserOverride
+ this.compareInfo = UseUserOverride
? GetCultureInfo(this._name).CompareInfo
: new CompareInfo(this);
- if (OkayToCacheClassWithCompatibilityBehavior)
- {
- this.compareInfo = temp;
- }
- else
- {
- return temp;
- }
}
return (compareInfo);
}
}
- private static bool OkayToCacheClassWithCompatibilityBehavior
- {
- get
- {
- return true;
- }
- }
-
////////////////////////////////////////////////////////////////////////
//
// TextInfo
// Make a new textInfo
TextInfo tempTextInfo = new TextInfo(_cultureData);
tempTextInfo.SetReadOnlyState(_isReadOnly);
-
- if (OkayToCacheClassWithCompatibilityBehavior)
- {
- textInfo = tempTextInfo;
- }
- else
- {
- return tempTextInfo;
- }
+ textInfo = tempTextInfo;
}
return (textInfo);
}