Remove disabled FEATURE_LEAK_CULTURE_INFO
authordanmosemsft <danmose@microsoft.com>
Mon, 23 Jan 2017 17:54:24 +0000 (09:54 -0800)
committerdanmosemsft <danmose@microsoft.com>
Mon, 23 Jan 2017 18:30:41 +0000 (10:30 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/e5573d3066a436f16b5cd66b75470df05d8ce70a

src/coreclr/clr.defines.targets
src/coreclr/clr.desktop.props
src/coreclr/src/mscorlib/src/System/Globalization/CultureInfo.cs
src/coreclr/src/mscorlib/src/System/Threading/Thread.cs

index 6795025..1d7e924 100644 (file)
@@ -40,7 +40,6 @@
         <CDefines Condition="'$(FeatureIsostoreLight)' == 'true'">$(CDefines);FEATURE_ISOSTORE_LIGHT</CDefines>
         <CDefines Condition="'$(FeatureIsymReader)' == 'true'">$(CDefines);FEATURE_ISYM_READER</CDefines>
         <CDefines Condition="'$(FeatureLazyCOWPages)' == 'true'">$(CDefines);FEATURE_LAZY_COW_PAGES</CDefines>
-        <CDefines Condition="'$(FeatureLeakCultureInfo)' == 'true'">$(CDefines);FEATURE_LEAK_CULTURE_INFO</CDefines>
         <CDefines Condition="'$(FeatureLegacyNetCFDbgHostControl)' == 'true'">$(CDefines);FEATURE_LEGACYNETCF_DBG_HOST_CONTROL</CDefines> 
         <CDefines Condition="'$(FeatureMacl)' == 'true'">$(CDefines);FEATURE_MACL</CDefines>
         <CDefines Condition="'$(FeatureManagedEtw)' == 'true'">$(CDefines);FEATURE_MANAGED_ETW</CDefines>
         <DefineConstants Condition="'$(FeatureIsolatedStorageQuotaEnforcement)' == 'true'">$(DefineConstants);FEATURE_ISOLATED_STORAGE_QUOTA_ENFORCEMENT</DefineConstants>
         <DefineConstants Condition="'$(FeatureIsostore)' == 'true'">$(DefineConstants);FEATURE_ISOSTORE</DefineConstants>
         <DefineConstants Condition="'$(FeatureIsostoreLight)' == 'true'">$(DefineConstants);FEATURE_ISOSTORE_LIGHT</DefineConstants>
-        <DefineConstants Condition="'$(FeatureLeakCultureInfo)' == 'true'">$(DefineConstants);FEATURE_LEAK_CULTURE_INFO</DefineConstants>
         <DefineConstants Condition="'$(FeatureMacl)' == 'true'">$(DefineConstants);FEATURE_MACL</DefineConstants>
         <DefineConstants Condition="'$(FeatureManagedEtw)' == 'true'">$(DefineConstants);FEATURE_MANAGED_ETW</DefineConstants>
         <DefineConstants Condition="'$(FeatureMethodRental)' == 'true'">$(DefineConstants);FEATURE_METHOD_RENTAL</DefineConstants>
index a7625de..8012d6d 100644 (file)
@@ -41,7 +41,6 @@
     <FeatureIsymReader>true</FeatureIsymReader>
     <!-- This is here for testing purposes only, and only on checked builds for x86/ARM -->
     <FeatureLazyCOWPages Condition="'$(_BuildType)'!='ret' and (('$(TargetArch)' == 'i386') or ('$(TargetArch)' == 'arm'))">true</FeatureLazyCOWPages>
-    <FeatureLeakCultureInfo>true</FeatureLeakCultureInfo>
     <FeatureMacl>true</FeatureMacl>
     <FeatureManagedEtw>true</FeatureManagedEtw>
     <FeatureMdaSupported>true</FeatureMdaSupported>
index 9f306c3..47d708b 100644 (file)
@@ -82,10 +82,6 @@ namespace System.Globalization {
         [NonSerialized]internal CultureData m_cultureData;
         
         [NonSerialized]internal bool m_isInherited;
-#if FEATURE_LEAK_CULTURE_INFO
-        [NonSerialized]private bool m_isSafeCrossDomain;
-        [NonSerialized]private int m_createdDomainID;
-#endif // !FEATURE_LEAK_CULTURE_INFO
         [NonSerialized]private CultureInfo m_consoleFallbackCulture;
 
         // Names are confusing.  Here are 3 names we have:
@@ -472,42 +468,6 @@ namespace System.Globalization {
         }
 #endregion Serialization
 
-#if FEATURE_LEAK_CULTURE_INFO
-        // Is it safe to send this CultureInfo as an instance member of a Thread cross AppDomain boundaries?
-        // For Silverlight, the answer is always no.
-        internal bool IsSafeCrossDomain {
-            get {
-                Debug.Assert(m_createdDomainID != 0, "[CultureInfo.IsSafeCrossDomain] m_createdDomainID != 0");
-                return m_isSafeCrossDomain;
-            }
-        }
-
-        internal int CreatedDomainID {
-            get {
-                Debug.Assert(m_createdDomainID != 0,  "[CultureInfo.CreatedDomain] m_createdDomainID != 0");
-                return m_createdDomainID;
-            }
-        }
-
-        internal void StartCrossDomainTracking() {
-        
-            // If we have decided about cross domain safety of this instance, we are done
-            if (m_createdDomainID != 0)
-                return;
-
-            // If FEATURE_LEAK_CULTURE_INFO isn't enabled, we never want to pass
-            // CultureInfo as an instance member of a Thread. 
-            if (CanSendCrossDomain())
-            {
-                m_isSafeCrossDomain = true;
-            }
-
-            // m_createdDomainID has to be assigned last. We use it to signal that we have
-            // completed the check.
-            System.Threading.Thread.MemoryBarrier();
-            m_createdDomainID = Thread.GetDomainID();
-        }
-#endif // FEATURE_LEAK_CULTURE_INFO
 
         // Is it safe to pass the CultureInfo cross AppDomain boundaries, not necessarily as an instance
         // member of Thread. This is different from IsSafeCrossDomain, which implies passing the CultureInfo
index 5f84a8c..339869d 100644 (file)
@@ -120,10 +120,6 @@ namespace System.Threading {
         private String          m_Name;
         private Delegate        m_Delegate;             // Delegate
 
-#if FEATURE_LEAK_CULTURE_INFO 
-        private CultureInfo     m_CurrentCulture;
-        private CultureInfo     m_CurrentUICulture;
-#endif
         private Object          m_ThreadStartArg;
 
         /*=========================================================================
@@ -164,32 +160,22 @@ namespace System.Threading {
         // Do not move! Order of above fields needs to be preserved for alignment
         // with native code
         // See code:#threadCultureInfo
-#if !FEATURE_LEAK_CULTURE_INFO
         [ThreadStatic]
         internal static CultureInfo     m_CurrentCulture;
         [ThreadStatic]
         internal static CultureInfo     m_CurrentUICulture;
-#endif
 
         static AsyncLocal<CultureInfo> s_asyncLocalCurrentCulture; 
         static AsyncLocal<CultureInfo> s_asyncLocalCurrentUICulture;
 
         static void AsyncLocalSetCurrentCulture(AsyncLocalValueChangedArgs<CultureInfo> args)
         {
-#if FEATURE_LEAK_CULTURE_INFO 
-            Thread.CurrentThread.m_CurrentCulture = args.CurrentValue;
-#else
             m_CurrentCulture = args.CurrentValue;
-#endif // FEATURE_LEAK_CULTURE_INFO
         }
 
         static void AsyncLocalSetCurrentUICulture(AsyncLocalValueChangedArgs<CultureInfo> args)
         {
-#if FEATURE_LEAK_CULTURE_INFO 
-            Thread.CurrentThread.m_CurrentUICulture = args.CurrentValue;
-#else
             m_CurrentUICulture = args.CurrentValue;
-#endif // FEATURE_LEAK_CULTURE_INFO
         }
 
         // Adding an empty default ctor for annotation purposes
@@ -600,10 +586,6 @@ namespace System.Threading {
         // - thread instance member cultures (CurrentCulture and CurrentUICulture) 
         //   confined within AppDomains
         // - changes to these properties don't affect the underlying native thread
-        //
-        // Ifdef:
-        // FEATURE_LEAK_CULTURE_INFO      : CultureInfos can leak across AppDomains, not
-        //                                  enabled in Silverlight
         // 
         // Implementation notes:
         // In Silverlight, culture members thread static (per Thread, per AppDomain). 
@@ -613,10 +595,6 @@ namespace System.Threading {
         // now need to special case resource lookup for mscorlib, which transitions to the 
         // default domain to lookup resources. See Environment.cs for more details.
         // 
-#if FEATURE_LEAK_CULTURE_INFO
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        static extern private bool nativeGetSafeCulture(Thread t, int appDomainId, bool isUI, ref CultureInfo safeCulture);
-#endif // FEATURE_LEAK_CULTURE_INFO
 
         // As the culture can be customized object then we cannot hold any 
         // reference to it before we check if it is safe because the app domain 
@@ -657,16 +635,8 @@ namespace System.Threading {
                 // If you add more pre-conditions to this method, check to see if you also need to 
                 // add them to CultureInfo.DefaultThreadCurrentUICulture.set.
 
-#if FEATURE_LEAK_CULTURE_INFO
-                if (nativeSetThreadUILocale(value.SortName) == false)
-                {
-                    throw new ArgumentException(Environment.GetResourceString("Argument_InvalidResourceCultureName", value.Name));
-                }
-                value.StartCrossDomainTracking();
-#else
                 if (m_CurrentUICulture == null && m_CurrentCulture == null)
                     nativeInitCultureAccessors();
-#endif
 
                 if (!AppContextSwitches.NoAsyncCurrentCulture)
                 {
@@ -685,8 +655,6 @@ namespace System.Threading {
             }
         }
 
-#if FEATURE_LEAK_CULTURE_INFO
-#endif
         internal CultureInfo GetCurrentUICultureNoAppX() {
 
             Contract.Ensures(Contract.Result<CultureInfo>() != null);
@@ -702,25 +670,11 @@ namespace System.Threading {
                 return (appDomainDefaultUICulture != null ? appDomainDefaultUICulture : CultureInfo.UserDefaultUICulture);
             }
 
-#if FEATURE_LEAK_CULTURE_INFO
-            CultureInfo culture = null;
-
-            if (!nativeGetSafeCulture(this, GetDomainID(), true, ref culture) || culture == null) {
-                return CultureInfo.UserDefaultUICulture;
-            }
-                
-            return culture;
-#else
             return m_CurrentUICulture;
 #endif
-#endif
         }
 
         // This returns the exposed context for a given context ID.
-#if FEATURE_LEAK_CULTURE_INFO
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        static extern private bool nativeSetThreadUILocale(String locale);
-#endif
 
         // As the culture can be customized object then we cannot hold any 
         // reference to it before we check if it is safe because the app domain 
@@ -749,8 +703,6 @@ namespace System.Threading {
                 }
             }
 
-#if FEATURE_LEAK_CULTURE_INFO
-#endif
             set {
                 if (null==value) {
                     throw new ArgumentNullException(nameof(value));
@@ -760,16 +712,8 @@ namespace System.Threading {
                 // If you add more pre-conditions to this method, check to see if you also need to 
                 // add them to CultureInfo.DefaultThreadCurrentCulture.set.
 
-#if FEATURE_LEAK_CULTURE_INFO
-                //If we can't set the nativeThreadLocale, we'll just let it stay
-                //at whatever value it had before.  This allows people who use
-                //just managed code not to be limited by the underlying OS.
-                CultureInfo.nativeSetThreadLocale(value.SortName);
-                value.StartCrossDomainTracking();
-#else
                 if (m_CurrentCulture == null && m_CurrentUICulture == null)
                     nativeInitCultureAccessors();
-#endif
 
                 if (!AppContextSwitches.NoAsyncCurrentCulture)
                 {
@@ -787,8 +731,6 @@ namespace System.Threading {
             }
         }
 
-#if FEATURE_LEAK_CULTURE_INFO
-#endif
         private CultureInfo GetCurrentCultureNoAppX() {
 
 #if FEATURE_COREFX_GLOBALIZATION
@@ -803,25 +745,13 @@ namespace System.Threading {
                 return (appDomainDefaultCulture != null ? appDomainDefaultCulture : CultureInfo.UserDefaultCulture);
             }
 
-#if FEATURE_LEAK_CULTURE_INFO
-            CultureInfo culture = null;
-              
-            if (!nativeGetSafeCulture(this, GetDomainID(), false, ref culture) || culture == null) {
-                return CultureInfo.UserDefaultCulture;
-            }
-                
-            return culture;
-#else
             return m_CurrentCulture;
 #endif
-#endif
         }
 
-#if !FEATURE_LEAK_CULTURE_INFO
         [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
         [SuppressUnmanagedCodeSecurity]
         private static extern void nativeInitCultureAccessors();
-#endif
 
         /*======================================================================
         ** Returns the current domain in which current thread is running.