This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/mscorlib/src/System/Globalization Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ public partial class CompareInfo : IDeserializationCallback
7575 [ NonSerialized ]
7676 private readonly bool _invariantMode = GlobalizationMode . Invariant ;
7777
78+ private int culture ; // Do not rename (binary serialization)
79+
7880 internal CompareInfo ( CultureInfo culture )
7981 {
8082 m_name = culture . _name ;
@@ -233,14 +235,26 @@ private void OnDeserialized(StreamingContext ctx)
233235
234236 private void OnDeserialized ( )
235237 {
236- if ( m_name != null )
238+ // If we didn't have a name, use the LCID
239+ if ( m_name == null )
240+ {
241+ // From whidbey, didn't have a name
242+ CultureInfo ci = CultureInfo . GetCultureInfo ( this . culture ) ;
243+ m_name = ci . _name ;
244+ }
245+ else
237246 {
238247 InitSort ( CultureInfo . GetCultureInfo ( m_name ) ) ;
239248 }
240249 }
241250
242251 [ OnSerializing ]
243- private void OnSerializing ( StreamingContext ctx ) { }
252+ private void OnSerializing ( StreamingContext ctx )
253+ {
254+ // This is merely for serialization compatibility with Whidbey/Orcas, it can go away when we don't want that compat any more.
255+ culture = CultureInfo . GetCultureInfo ( this . Name ) . LCID ; // This is the lcid of the constructing culture (still have to dereference to get target sort)
256+ Contract . Assert ( m_name != null , "CompareInfo.OnSerializing - expected m_name to be set already" ) ;
257+ }
244258
245259 ///////////////////////////----- Name -----/////////////////////////////////
246260 //
You can’t perform that action at this time.
0 commit comments