From: Viktor Hofer Date: Mon, 19 Jun 2017 20:59:38 +0000 (+0200) Subject: Fixing CompareInfo AssemblyMode.Full serialization between Core <--> Desktop (dotnet... X-Git-Tag: submit/tizen/20210909.063632~11030^2~6925^2~387 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=630c1db446d199cb8ba18bda1126f2fbb3de67f0;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fixing CompareInfo AssemblyMode.Full serialization between Core <--> Desktop (dotnet/coreclr#12365) * Fixing CompareInfo AssemblyMode.Full serialization * Adding reason why culture field is introduced Commit migrated from https://github.com/dotnet/coreclr/commit/b2cd406d76546d075cdcb79c3255c113f7f1dbfa --- diff --git a/src/coreclr/src/mscorlib/src/System/Globalization/CompareInfo.cs b/src/coreclr/src/mscorlib/src/System/Globalization/CompareInfo.cs index b7ab5ad..bfdbdc5 100644 --- a/src/coreclr/src/mscorlib/src/System/Globalization/CompareInfo.cs +++ b/src/coreclr/src/mscorlib/src/System/Globalization/CompareInfo.cs @@ -75,6 +75,8 @@ namespace System.Globalization // _invariantMode is defined for the perf reason as accessing the instance field is faster than access the static property GlobalizationMode.Invariant [NonSerialized] private readonly bool _invariantMode = GlobalizationMode.Invariant; + + private int culture; // Do not rename (binary serialization). The fields sole purpose is to support Desktop serialization. internal CompareInfo(CultureInfo culture) { @@ -234,14 +236,26 @@ namespace System.Globalization private void OnDeserialized() { - if (m_name != null) + // If we didn't have a name, use the LCID + if (m_name == null) + { + // From whidbey, didn't have a name + CultureInfo ci = CultureInfo.GetCultureInfo(this.culture); + m_name = ci._name; + } + else { InitSort(CultureInfo.GetCultureInfo(m_name)); } } [OnSerializing] - private void OnSerializing(StreamingContext ctx) { } + private void OnSerializing(StreamingContext ctx) + { + // This is merely for serialization compatibility with Whidbey/Orcas, it can go away when we don't want that compat any more. + culture = CultureInfo.GetCultureInfo(this.Name).LCID; // This is the lcid of the constructing culture (still have to dereference to get target sort) + Contract.Assert(m_name != null, "CompareInfo.OnSerializing - expected m_name to be set already"); + } ///////////////////////////----- Name -----///////////////////////////////// //