diff options
author | jiseob.jang <jiseob.jang@samsung.com> | 2017-09-06 20:40:24 +0900 |
---|---|---|
committer | jiseob.jang <jiseob.jang@samsung.com> | 2017-09-07 11:55:42 +0900 |
commit | cb9516da9df966079e5a34490139eec68c38dafa (patch) | |
tree | 39d5565943e78c35dd013cc771ed2980788fff38 /src/mscorlib/src/System/Globalization | |
parent | 61d6a817e39d3bae0f47dbc09838d51db22a5d30 (diff) | |
download | coreclr-cb9516da9df966079e5a34490139eec68c38dafa.tar.gz coreclr-cb9516da9df966079e5a34490139eec68c38dafa.tar.bz2 coreclr-cb9516da9df966079e5a34490139eec68c38dafa.zip |
Imported Upstream version 2.0.0.12082upstream/2.0.0.12082
Diffstat (limited to 'src/mscorlib/src/System/Globalization')
3 files changed, 55 insertions, 22 deletions
diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs b/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs index eb4dc5613e..0df5463a2f 100644 --- a/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs +++ b/src/mscorlib/src/System/Globalization/CompareInfo.Windows.cs @@ -469,6 +469,7 @@ namespace System.Globalization Debug.Assert(!_invariantMode); Interop.Kernel32.NlsVersionInfoEx nlsVersion = new Interop.Kernel32.NlsVersionInfoEx(); + nlsVersion.dwNLSVersionInfoSize = Marshal.SizeOf(typeof(Interop.Kernel32.NlsVersionInfoEx)); Interop.Kernel32.GetNLSVersionEx(Interop.Kernel32.COMPARE_STRING, _sortName, &nlsVersion); return new SortVersion( nlsVersion.dwNLSVersion, diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.cs b/src/mscorlib/src/System/Globalization/CompareInfo.cs index 593e86415d..bfdbdc546b 100644 --- a/src/mscorlib/src/System/Globalization/CompareInfo.cs +++ b/src/mscorlib/src/System/Globalization/CompareInfo.cs @@ -34,6 +34,7 @@ namespace System.Globalization } [Serializable] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public partial class CompareInfo : IDeserializationCallback { // Mask used to check if IndexOf()/LastIndexOf()/IsPrefix()/IsPostfix() has the right flags. @@ -69,11 +70,13 @@ namespace System.Globalization private string _sortName; // The name that defines our behavior. [OptionalField(VersionAdded = 3)] - private SortVersion m_sortVersion; // Do not rename (binary serialization) + private SortVersion m_SortVersion; // Do not rename (binary serialization) // _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) { @@ -233,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 -----///////////////////////////////// // @@ -1208,11 +1223,11 @@ namespace System.Globalization { get { - if (m_sortVersion == null) + if (m_SortVersion == null) { if (_invariantMode) { - m_sortVersion = new SortVersion(0, CultureInfo.LOCALE_INVARIANT, new Guid(0, 0, 0, 0, 0, 0, 0, + m_SortVersion = new SortVersion(0, CultureInfo.LOCALE_INVARIANT, new Guid(0, 0, 0, 0, 0, 0, 0, (byte) (CultureInfo.LOCALE_INVARIANT >> 24), (byte) ((CultureInfo.LOCALE_INVARIANT & 0x00FF0000) >> 16), (byte) ((CultureInfo.LOCALE_INVARIANT & 0x0000FF00) >> 8), @@ -1220,11 +1235,11 @@ namespace System.Globalization } else { - m_sortVersion = GetSortVersion(); + m_SortVersion = GetSortVersion(); } } - return m_sortVersion; + return m_SortVersion; } } diff --git a/src/mscorlib/src/System/Globalization/CultureInfo.cs b/src/mscorlib/src/System/Globalization/CultureInfo.cs index 16e2d291a1..ee64bc52e2 100644 --- a/src/mscorlib/src/System/Globalization/CultureInfo.cs +++ b/src/mscorlib/src/System/Globalization/CultureInfo.cs @@ -206,6 +206,26 @@ namespace System.Globalization InitializeFromName(name, useUserOverride); } + private CultureInfo(CultureData cultureData) + { + Debug.Assert(cultureData != null); + _cultureData = cultureData; + _name = cultureData.CultureName; + _isInherited = false; + } + + private static CultureInfo CreateCultureInfoNoThrow(string name, bool useUserOverride) + { + Debug.Assert(name != null); + CultureData cultureData = CultureData.GetCultureData(name, useUserOverride); + if (cultureData == null) + { + return null; + } + + return new CultureInfo(cultureData); + } + public CultureInfo(int culture) : this(culture, true) { } @@ -533,25 +553,22 @@ namespace System.Globalization { if (null == _parent) { - try - { - string parentName = _cultureData.SPARENT; + string parentName = _cultureData.SPARENT; - if (String.IsNullOrEmpty(parentName)) + if (String.IsNullOrEmpty(parentName)) + { + _parent = InvariantCulture; + } + else + { + _parent = CreateCultureInfoNoThrow(parentName, _cultureData.UseUserOverride); + if (_parent == null) { + // For whatever reason our IPARENT or SPARENT wasn't correct, so use invariant + // We can't allow ourselves to fail. In case of custom cultures the parent of the + // current custom culture isn't installed. _parent = InvariantCulture; } - else - { - _parent = new CultureInfo(parentName, _cultureData.UseUserOverride); - } - } - catch (ArgumentException) - { - // For whatever reason our IPARENT or SPARENT wasn't correct, so use invariant - // We can't allow ourselves to fail. In case of custom cultures the parent of the - // current custom culture isn't installed. - _parent = InvariantCulture; } } return _parent; |