Remove cross appdomains cultures checks (#9328)
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Sat, 4 Feb 2017 02:27:43 +0000 (18:27 -0800)
committerGitHub <noreply@github.com>
Sat, 4 Feb 2017 02:27:43 +0000 (18:27 -0800)
* Remove cross appdomains cultures checks

In the ful framework, CultureInfo and other globalization objects are marked as agile which means it can cross the appdomains. In coreclr we don't have multiple appdomains anymore so these checks are not really needed.
removing these checks will make coreclr consistent when running on Windows and other OS's

* Remove un-needed resource entry

src/mscorlib/src/System.Private.CoreLib.txt
src/mscorlib/src/System/Globalization/CultureInfo.cs
src/mscorlib/src/System/Globalization/DateTimeFormatInfo.cs

index 5fad0bd..b4e9e29 100644 (file)
@@ -1052,7 +1052,6 @@ InvalidOperation_CantCancelCtrlBreak = Applications may not prevent control-brea
 InvalidOperation_CalledTwice = The method cannot be called twice on the same instance.
 InvalidOperation_CollectionCorrupted = A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
 InvalidOperation_CriticalTransparentAreMutuallyExclusive = SecurityTransparent and SecurityCritical attributes cannot be applied to the assembly scope at the same time.
-InvalidOperation_SubclassedObject = Cannot set sub-classed {0} object to {1} object.
 InvalidOperation_ExceptionStateCrossAppDomain = Thread.ExceptionState cannot access an ExceptionState from a different AppDomain.
 InvalidOperation_DebuggerLaunchFailed = Debugger unable to launch.
 InvalidOperation_ApartmentStateSwitchFailed = Failed to set the specified COM apartment state.
index 47d708b..4674baa 100644 (file)
@@ -366,25 +366,6 @@ namespace System.Globalization {
         }
 #endif // FEATURE_USE_LCID
 
-        //
-        // CheckDomainSafetyObject throw if the object is customized object which cannot be attached to 
-        // other object (like CultureInfo or DateTimeFormatInfo).
-        //
-
-        internal static void CheckDomainSafetyObject(Object obj, Object container)
-        {
-            if (obj.GetType().Assembly != typeof(System.Globalization.CultureInfo).Assembly) {
-                
-                throw new InvalidOperationException(
-                            String.Format(
-                                CultureInfo.CurrentCulture, 
-                                Environment.GetResourceString("InvalidOperation_SubclassedObject"), 
-                                obj.GetType(),
-                                container.GetType()));
-            }
-            Contract.EndContractBlock();
-        }
-
 #region Serialization
         // We need to store the override from the culture data record.
         private bool    m_useUserOverride;
@@ -417,21 +398,6 @@ namespace System.Globalization {
             }
 #endif
             m_isInherited = (this.GetType() != typeof(System.Globalization.CultureInfo));
-
-            // in case we have non customized CultureInfo object we shouldn't allow any customized object  
-            // to be attached to it for cross app domain safety.
-            if (this.GetType().Assembly == typeof(System.Globalization.CultureInfo).Assembly)
-            {
-                if (textInfo != null)
-                {
-                    CheckDomainSafetyObject(textInfo, this);
-                }
-                
-                if (compareInfo != null)
-                {
-                    CheckDomainSafetyObject(compareInfo, this);
-                }
-            }
         }
 
 #if FEATURE_USE_LCID
index ecbc6db..b745b0b 100644 (file)
@@ -408,10 +408,6 @@ namespace System.Globalization {
                 calendar = (Calendar) GregorianCalendar.GetDefaultInstance().Clone();
                 calendar.SetReadOnlyState(m_isReadOnly);
             }
-            else
-            {
-                CultureInfo.CheckDomainSafetyObject(calendar, this);
-            }
             InitializeOverridableProperties(m_cultureData, calendar.ID);
 
             //
@@ -587,12 +583,6 @@ namespace System.Globalization {
                     return;
                 }
 
-                //
-                // Because the culture is agile object which can be attached to a thread and then thread can travel
-                // to another app domain then we prevent attaching any customized object to culture that we cannot contol.
-                //
-                CultureInfo.CheckDomainSafetyObject(value, this);
-
                 for (int i = 0; i < this.OptionalCalendars.Length; i++)
                 {
                     if (this.OptionalCalendars[i] == value.ID)