diff options
author | Viktor Hofer <viktor.hofer@microsoft.com> | 2017-06-09 18:08:13 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-06-09 20:15:45 +0300 |
commit | 570d7b9b7ace5349707a39d62e914b32ea5ed3d5 (patch) | |
tree | 878fde80a39a3b749c27cc786b59e9341e7162e9 | |
parent | 69808728c3f88e983c49d3b0b553f00b8a125114 (diff) |
DateTime serialization fixed, added attention labels to serialized fields (#12181)
* DateTime serialization fixed, added attention labels to serialized fields
* CultureAwareComparer serialization fix
* Order or property fixed
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
7 files changed, 29 insertions, 26 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs b/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs index 0815c9331..3c1c0befa 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs @@ -12,8 +12,8 @@ namespace System.Collections [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct DictionaryEntry { - private Object _key; - private Object _value; + private Object _key; // Do not rename (binary serialization) + private Object _value; // Do not rename (binary serialization) // Constructs a new DictionaryEnumerator by setting the Key // and Value fields appropriately. diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyValuePair.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyValuePair.cs index 628021806..aeafecd95 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyValuePair.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyValuePair.cs @@ -49,8 +49,8 @@ namespace System.Collections.Generic [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct KeyValuePair<TKey, TValue> { - private TKey key; // DO NOT change the field name, it's required for compatibility with desktop .NET as it appears in serialization payload. - private TValue value; // DO NOT change the field name, it's required for compatibility with desktop .NET as it appears in serialization payload. + private TKey key; // Do not rename (binary serialization) + private TValue value; // Do not rename (binary serialization) public KeyValuePair(TKey key, TValue value) { diff --git a/src/System.Private.CoreLib/shared/System/DateTime.cs b/src/System.Private.CoreLib/shared/System/DateTime.cs index 02f07d286..4fd9727fc 100644 --- a/src/System.Private.CoreLib/shared/System/DateTime.cs +++ b/src/System.Private.CoreLib/shared/System/DateTime.cs @@ -126,8 +126,8 @@ namespace System private const UInt64 KindLocalAmbiguousDst = 0xC000000000000000; private const Int32 KindShift = 62; - private const String TicksField = "ticks"; - private const String DateDataField = "_dateData"; + private const String TicksField = "ticks"; // Do not rename (binary serialization) + private const String DateDataField = "dateData"; // Do not rename (binary serialization) // The data is stored as an unsigned 64-bit integeter // Bits 01-62: The value of 100-nanosecond ticks where 0 represents 1/1/0001 12:00am, up until the value diff --git a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs index 6df35fed1..ab35bdb0f 100644 --- a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs +++ b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs @@ -574,8 +574,8 @@ namespace System throw new ArgumentNullException(nameof(info)); } - info.AddValue("DateTime", _dateTime); - info.AddValue("OffsetMinutes", _offsetMinutes); + info.AddValue("DateTime", _dateTime); // Do not rename (binary serialization) + info.AddValue("OffsetMinutes", _offsetMinutes); // Do not rename (binary serialization) } @@ -586,8 +586,8 @@ namespace System throw new ArgumentNullException(nameof(info)); } - _dateTime = (DateTime)info.GetValue("DateTime", typeof(DateTime)); - _offsetMinutes = (Int16)info.GetValue("OffsetMinutes", typeof(Int16)); + _dateTime = (DateTime)info.GetValue("DateTime", typeof(DateTime)); // Do not rename (binary serialization) + _offsetMinutes = (Int16)info.GetValue("OffsetMinutes", typeof(Int16)); // Do not rename (binary serialization) } // Returns the hash code for this DateTimeOffset. diff --git a/src/System.Private.CoreLib/shared/System/StringComparer.cs b/src/System.Private.CoreLib/shared/System/StringComparer.cs index 765f43ea1..4b6193c18 100644 --- a/src/System.Private.CoreLib/shared/System/StringComparer.cs +++ b/src/System.Private.CoreLib/shared/System/StringComparer.cs @@ -174,28 +174,30 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class CultureAwareComparer : StringComparer { - private readonly CompareInfo _compareInfo; - private readonly CompareOptions _options; + private readonly CompareInfo _compareInfo; // Do not rename (binary serialization) + private readonly bool _ignoreCase; // Do not rename (binary serialization) internal CultureAwareComparer(CultureInfo culture, bool ignoreCase) { _compareInfo = culture.CompareInfo; - _options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + _ignoreCase = ignoreCase; } + private CompareOptions Options => _ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + public override int Compare(string x, string y) { if (object.ReferenceEquals(x, y)) return 0; if (x == null) return -1; if (y == null) return 1; - return _compareInfo.Compare(x, y, _options); + return _compareInfo.Compare(x, y, Options); } public override bool Equals(string x, string y) { if (object.ReferenceEquals(x, y)) return true; if (x == null || y == null) return false; - return _compareInfo.Compare(x, y, _options) == 0; + return _compareInfo.Compare(x, y, Options) == 0; } public override int GetHashCode(string obj) @@ -204,7 +206,7 @@ namespace System { throw new ArgumentNullException(nameof(obj)); } - return _compareInfo.GetHashCodeOfString(obj, _options); + return _compareInfo.GetHashCodeOfString(obj, Options); } // Equals method for the comparer itself. @@ -213,14 +215,14 @@ namespace System CultureAwareComparer comparer = obj as CultureAwareComparer; return comparer != null && - _options == comparer._options && + _ignoreCase == comparer._ignoreCase && _compareInfo.Equals(comparer._compareInfo); } public override int GetHashCode() { int hashCode = _compareInfo.GetHashCode(); - return _options == CompareOptions.None ? hashCode : ~hashCode; + return _ignoreCase ? ~hashCode : hashCode; } } diff --git a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs index 29f0cdb18..1167016cc 100644 --- a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs @@ -59,10 +59,11 @@ namespace System.Text // // internal const int DefaultCapacity = 16; - private const String CapacityField = "Capacity"; - private const String MaxCapacityField = "m_MaxCapacity"; - private const String StringValueField = "m_StringValue"; - private const String ThreadIDField = "m_currentThread"; + private const String CapacityField = "Capacity"; // Do not rename (binary serialization) + private const String MaxCapacityField = "m_MaxCapacity"; // Do not rename (binary serialization) + private const String StringValueField = "m_StringValue"; // Do not rename (binary serialization) + private const String ThreadIDField = "m_currentThread"; // Do not rename (binary serialization) + // We want to keep chunk arrays out of large object heap (< 85K bytes ~ 40K chars) to be sure. // Making the maximum chunk size big means less allocation code called, but also more waste // in unused characters and slower inserts / replaces (since you do need to slide characters over diff --git a/src/System.Private.CoreLib/shared/System/Version.cs b/src/System.Private.CoreLib/shared/System/Version.cs index b88db7e6b..a2140ab13 100644 --- a/src/System.Private.CoreLib/shared/System/Version.cs +++ b/src/System.Private.CoreLib/shared/System/Version.cs @@ -21,10 +21,10 @@ namespace System , IComparable<Version>, IEquatable<Version> { // AssemblyName depends on the order staying the same - private readonly int _Major; - private readonly int _Minor; - private readonly int _Build = -1; - private readonly int _Revision = -1; + private readonly int _Major; // Do not rename (binary serialization) + private readonly int _Minor; // Do not rename (binary serialization) + private readonly int _Build = -1; // Do not rename (binary serialization) + private readonly int _Revision = -1; // Do not rename (binary serialization) public Version(int major, int minor, int build, int revision) { |