Move a few more files to shared CoreLib partition
authorJan Kotas <jkotas@microsoft.com>
Sun, 16 Apr 2017 22:14:48 +0000 (15:14 -0700)
committerJan Kotas <jkotas@microsoft.com>
Mon, 1 May 2017 19:02:04 +0000 (12:02 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/b11928aa219f3caded8ba39a946cf4bec9b7b5ed

src/coreclr/src/mscorlib/System.Private.CoreLib.csproj
src/coreclr/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs [new file with mode: 0644]
src/coreclr/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs [new file with mode: 0644]
src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/coreclr/src/mscorlib/shared/System/ArgumentOutOfRangeException.cs [moved from src/coreclr/src/mscorlib/src/System/ArgumentOutOfRangeException.cs with 73% similarity]
src/coreclr/src/mscorlib/shared/System/BadImageFormatException.cs [moved from src/coreclr/src/mscorlib/src/System/BadImageFormatException.cs with 64% similarity]
src/coreclr/src/mscorlib/shared/System/Resources/ResourceFallbackManager.cs [moved from src/coreclr/src/mscorlib/src/System/Resources/ResourceFallbackManager.cs with 83% similarity]
src/coreclr/src/mscorlib/shared/System/Resources/ResourceSet.cs [moved from src/coreclr/src/mscorlib/src/System/Resources/ResourceSet.cs with 69% similarity]
src/coreclr/src/mscorlib/shared/System/Resources/RuntimeResourceSet.cs [moved from src/coreclr/src/mscorlib/src/System/Resources/RuntimeResourceSet.cs with 91% similarity]
src/coreclr/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs [deleted file]

index f00baa2..a7fb42b 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\IAppDomainPauseManager.cs" />
     <Compile Include="$(BclSourcesRoot)\System\AppDomainAttributes.cs" />
     <Compile Include="$(BclSourcesRoot)\System\AppDomainUnloadedException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\ArgumentOutOfRangeException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\ArgIterator.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Attribute.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\BadImageFormatException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\BitConverter.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Boolean.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Buffer.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Resources\IResourceGroveler.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Resources\LooselyLinkedResourceReference.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Resources\ManifestBasedResourceGroveler.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Resources\ResourceFallbackManager.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Resources\ResourceManager.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Resources\ResourceReader.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Resources\ResourceSet.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Resources\RuntimeResourceSet.cs" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Nullable.cs" />
     <Compile Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeFindHandle.cs" />
     <Compile Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs" />
     <Compile Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeWaitHandle.cs" />
-    <Compile Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\Win32SafeHandles.cs" />
     <Compile Condition="'$(FeatureWin32Registry)' == 'true'" Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs" />
   </ItemGroup>
   <ItemGroup>
diff --git a/src/coreclr/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs b/src/coreclr/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs
new file mode 100644 (file)
index 0000000..5415f2c
--- /dev/null
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Microsoft.Win32.SafeHandles
+{
+    // Class of safe handle which uses only -1 as an invalid handle.
+    public abstract class SafeHandleMinusOneIsInvalid : SafeHandle
+    {
+        protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle)
+        {
+        }
+
+        public override bool IsInvalid => handle == new IntPtr(-1);
+    }
+}
diff --git a/src/coreclr/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs b/src/coreclr/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs
new file mode 100644 (file)
index 0000000..8d0220b
--- /dev/null
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Microsoft.Win32.SafeHandles
+{
+    // Class of safe handle which uses 0 or -1 as an invalid handle.
+    public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle
+    {
+        protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+        {
+        }
+
+        public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
+    }
+}
index 5a6cbf4..00d0796 100644 (file)
   <ItemGroup>
     <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleMinusOneIsInvalid.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleZeroOrMinusOneIsInvalid.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Action.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ApplicationException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ArgumentException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ArgumentNullException.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\ArgumentOutOfRangeException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ArithmeticException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ArrayTypeMismatchException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\AssemblyLoadEventArgs.cs" />
@@ -27,6 +30,7 @@
     <Compile Include="$(MSBuildThisFileDirectory)System\AsyncCallback.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\AttributeTargets.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\AttributeUsageAttribute.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\BadImageFormatException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Buffers\ArrayPool.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Buffers\ConfigurableArrayPool.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Buffers\TlsOverPerCoreLockedStacksArrayPool.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\MissingManifestResourceException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\MissingSatelliteAssemblyException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\NeutralResourcesLanguageAttribute.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceFallbackManager.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceSet.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceTypeCode.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Resources\RuntimeResourceSet.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\SatelliteContractVersionAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Resources\UltimateResourceFallbackLocation.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\AccessedThroughPropertyAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\FormattableStringFactory.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IAsyncStateMachine.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IndexerNameAttribute.cs"/>
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\INotifyCompletion.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsConst.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsVolatile.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IteratorStateMachineAttribute.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\EncodingProvider.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\Normalization.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.cs"/>
+    <Compile Include="$(MSBuildThisFileDirectory)System\Text\UnicodeEncoding.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF32Encoding.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF8Encoding.cs"/>
-    <Compile Include="$(MSBuildThisFileDirectory)System\Text\UnicodeEncoding.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\ThreadAttributes.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\AbandonedMutexException.cs"/>
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ApartmentState.cs"/>
 **
 =============================================================================*/
 
-
-using System;
-using System.Runtime.Remoting;
-using System.Runtime.Serialization;
 using System.Globalization;
-using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
 
 namespace System
 {
     // The ArgumentOutOfRangeException is thrown when an argument 
     // is outside the legal range for that argument.  
     [Serializable]
-    public class ArgumentOutOfRangeException : ArgumentException, ISerializable
+    public class ArgumentOutOfRangeException : ArgumentException
     {
-        private static volatile String _rangeMessage;
-        private Object m_actualValue;
-
-        private static String RangeMessage
-        {
-            get
-            {
-                if (_rangeMessage == null)
-                    _rangeMessage = SR.Arg_ArgumentOutOfRangeException;
-                return _rangeMessage;
-            }
-        }
+        private Object _actualValue;
 
         // Creates a new ArgumentOutOfRangeException with its message 
         // string set to a default message explaining an argument was out of range.
         public ArgumentOutOfRangeException()
-            : base(RangeMessage)
+            : base(SR.Arg_ArgumentOutOfRangeException)
         {
             HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
         }
 
         public ArgumentOutOfRangeException(String paramName)
-            : base(RangeMessage, paramName)
+            : base(SR.Arg_ArgumentOutOfRangeException, paramName)
         {
             HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
         }
@@ -70,18 +55,30 @@ namespace System
         public ArgumentOutOfRangeException(String paramName, Object actualValue, String message)
             : base(message, paramName)
         {
-            m_actualValue = actualValue;
+            _actualValue = actualValue;
             HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
         }
 
+        protected ArgumentOutOfRangeException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+            _actualValue = info.GetValue("ActualValue", typeof(Object));
+        }
+
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("ActualValue", _actualValue, typeof(Object));
+        }
+
         public override String Message
         {
             get
             {
                 String s = base.Message;
-                if (m_actualValue != null)
+                if (_actualValue != null)
                 {
-                    String valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, m_actualValue.ToString());
+                    String valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, _actualValue.ToString());
                     if (s == null)
                         return valueMessage;
                     return s + Environment.NewLine + valueMessage;
@@ -96,23 +93,7 @@ namespace System
         // want to avoid sticking printf's in their code.
         public virtual Object ActualValue
         {
-            get { return m_actualValue; }
-        }
-
-        public override void GetObjectData(SerializationInfo info, StreamingContext context)
-        {
-            if (info == null)
-            {
-                throw new ArgumentNullException(nameof(info));
-            }
-            Contract.EndContractBlock();
-            base.GetObjectData(info, context);
-            info.AddValue("ActualValue", m_actualValue, typeof(Object));
-        }
-
-        protected ArgumentOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context)
-        {
-            m_actualValue = info.GetValue("ActualValue", typeof(Object));
+            get { return _actualValue; }
         }
     }
 }
 ** 
 ===========================================================*/
 
+using System.Globalization;
+using System.IO;
+using System.Runtime.Serialization;
+
 namespace System
 {
-    using System;
-    using System.Runtime.Serialization;
-    using FileLoadException = System.IO.FileLoadException;
-    using SecurityException = System.Security.SecurityException;
-    using System.Globalization;
-
     [Serializable]
     public class BadImageFormatException : SystemException
     {
@@ -56,6 +54,21 @@ namespace System
             _fileName = fileName;
         }
 
+        protected BadImageFormatException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+            _fileName = info.GetString("BadImageFormat_FileName");
+            _fusionLog = info.GetString("BadImageFormat_FusionLog");
+        }
+
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+
+            info.AddValue("BadImageFormat_FileName", _fileName, typeof(String));
+            info.AddValue("BadImageFormat_FusionLog", _fusionLog, typeof(String));
+        }
+
         public override String Message
         {
             get
@@ -70,7 +83,7 @@ namespace System
             if (_message == null)
             {
                 if ((_fileName == null) &&
-                    (HResult == System.__HResults.COR_E_EXCEPTION))
+                    (HResult == __HResults.COR_E_EXCEPTION))
                     _message = SR.Arg_BadImageFormatException;
 
                 else
@@ -85,7 +98,7 @@ namespace System
 
         public override String ToString()
         {
-            String s = GetType().FullName + ": " + Message;
+            String s = GetType().ToString() + ": " + Message;
 
             if (_fileName != null && _fileName.Length != 0)
                 s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName);
@@ -95,68 +108,22 @@ namespace System
 
             if (StackTrace != null)
                 s += Environment.NewLine + StackTrace;
-            try
-            {
-                if (FusionLog != null)
-                {
-                    if (s == null)
-                        s = " ";
-                    s += Environment.NewLine;
-                    s += Environment.NewLine;
-                    s += FusionLog;
-                }
-            }
-            catch (SecurityException)
-            {
-            }
-            return s;
-        }
 
-        protected BadImageFormatException(SerializationInfo info, StreamingContext context) : base(info, context)
-        {
-            // Base class constructor will check info != null.
-
-            _fileName = info.GetString("BadImageFormat_FileName");
-            try
+            if (_fusionLog != null)
             {
-                _fusionLog = info.GetString("BadImageFormat_FusionLog");
+                if (s == null)
+                    s = " ";
+                s += Environment.NewLine;
+                s += Environment.NewLine;
+                s += _fusionLog;
             }
-            catch
-            {
-                _fusionLog = null;
-            }
-        }
 
-        private BadImageFormatException(String fileName, String fusionLog, int hResult)
-            : base(null)
-        {
-            HResult = hResult;
-            _fileName = fileName;
-            _fusionLog = fusionLog;
-            SetMessageField();
+            return s;
         }
 
         public String FusionLog
         {
-#pragma warning disable CS0618 // Type or member is obsolete
-#pragma warning restore CS0618 // Type or member is obsolete
             get { return _fusionLog; }
         }
-
-        public override void GetObjectData(SerializationInfo info, StreamingContext context)
-        {
-            // Serialize data for our base classes.  base will verify info != null.
-            base.GetObjectData(info, context);
-
-            // Serialize data for this class
-            info.AddValue("BadImageFormat_FileName", _fileName, typeof(String));
-            try
-            {
-                info.AddValue("BadImageFormat_FusionLog", FusionLog, typeof(String));
-            }
-            catch (SecurityException)
-            {
-            }
-        }
     }
 }
@@ -30,15 +30,6 @@ namespace System.Resources
         private CultureInfo m_neutralResourcesCulture;
         private bool m_useParents;
 
-        // This is a cache of the thread, process, user, and OS-preferred fallback cultures.
-        // However, each thread may have a different value, and these may change during the
-        // lifetime of the process.  So this cache must be verified each time we use it.
-        // Hence, we'll keep an array of strings for culture names & check it each time,
-        // but we'll really cache an array of CultureInfo's.  Using thread-local statics
-        // as well to avoid differences across threads.
-        [ThreadStatic]
-        private static CultureInfo[] cachedOsFallbackArray;
-
         internal ResourceFallbackManager(CultureInfo startingCulture, CultureInfo neutralResourcesCulture, bool useParents)
         {
             if (startingCulture != null)
 ** 
 ===========================================================*/
 
+using System;
+using System.Collections;
+using System.IO;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.Runtime.Versioning;
+using System.Diagnostics.Contracts;
+using System.Collections.Generic;
+
 namespace System.Resources
 {
-    using System;
-    using System.Collections;
-    using System.IO;
-    using System.Globalization;
-    using System.Runtime.InteropServices;
-    using System.Reflection;
-    using System.Runtime.Serialization;
-    using System.Runtime.Versioning;
-    using System.Diagnostics.Contracts;
-
     // A ResourceSet stores all the resources defined in one particular CultureInfo.
     // 
     // The method used to load resources is straightforward - this class
     // enumerates over an IResourceReader, loading every name and value, and 
     // stores them in a hash table.  Custom IResourceReaders can be used.
-    // 
+    //
     [Serializable]
     public class ResourceSet : IDisposable, IEnumerable
     {
-        [NonSerialized] protected IResourceReader Reader;
-        internal Hashtable Table;
+        [NonSerialized]
+        protected IResourceReader Reader;
 
-        private Hashtable _caseInsensitiveTable;  // For case-insensitive lookups.
-
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-        [OptionalField]
-        private Assembly _assembly;  // For LooselyLinkedResourceReferences
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
+        private Dictionary<object, object> _table;
+        private Dictionary<object, object> _caseInsensitiveTable;  // For case-insensitive lookups.
 
         protected ResourceSet()
         {
@@ -68,16 +65,6 @@ namespace System.Resources
             ReadResources();
         }
 
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-        public ResourceSet(String fileName, Assembly assembly)
-        {
-            Reader = new ResourceReader(fileName);
-            CommonInit();
-            _assembly = assembly;
-            ReadResources();
-        }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
-
         // Creates a ResourceSet using the system default ResourceReader
         // implementation.  Use this constructor to read from an open stream 
         // of data.
@@ -89,16 +76,6 @@ namespace System.Resources
             ReadResources();
         }
 
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-        public ResourceSet(Stream stream, Assembly assembly)
-        {
-            Reader = new ResourceReader(stream);
-            CommonInit();
-            _assembly = assembly;
-            ReadResources();
-        }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
-
         public ResourceSet(IResourceReader reader)
         {
             if (reader == null)
@@ -109,22 +86,9 @@ namespace System.Resources
             ReadResources();
         }
 
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-        public ResourceSet(IResourceReader reader, Assembly assembly)
-        {
-            if (reader == null)
-                throw new ArgumentNullException(nameof(reader));
-            Contract.EndContractBlock();
-            Reader = reader;
-            CommonInit();
-            _assembly = assembly;
-            ReadResources();
-        }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
-
         private void CommonInit()
         {
-            Table = new Hashtable();
+            _table = new Dictionary<object, object>();
         }
 
         // Closes and releases any resources used by this ResourceSet, if any.
@@ -148,7 +112,7 @@ namespace System.Resources
             }
             Reader = null;
             _caseInsensitiveTable = null;
-            Table = null;
+            _table = null;
         }
 
         public void Dispose()
@@ -156,15 +120,6 @@ namespace System.Resources
             Dispose(true);
         }
 
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-        // Optional - used for resolving assembly manifest resource references.
-        // This can safely be null.
-        public Assembly Assembly {
-            get { return _assembly; }
-            /*protected*/ set { _assembly = value; }
-        }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
-
         // Returns the preferred IResourceReader class for this kind of ResourceSet.
         // Subclasses of ResourceSet using their own Readers &; should override
         // GetDefaultReader and GetDefaultWriter.
@@ -178,7 +133,8 @@ namespace System.Resources
         // GetDefaultReader and GetDefaultWriter.
         public virtual Type GetDefaultWriter()
         {
-            return Type.GetType("System.Resources.ResourceWriter, System.Resources.Writer, Version=4.0.1.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken, throwOnError: true);
+            Assembly resourceWriterAssembly = Assembly.Load("System.Resources.Writer, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
+            return resourceWriterAssembly.GetType("System.Resources.ResourceWriter", true);
         }
 
         public virtual IDictionaryEnumerator GetEnumerator()
@@ -193,7 +149,7 @@ namespace System.Resources
 
         private IDictionaryEnumerator GetEnumeratorHelper()
         {
-            Hashtable copyOfTable = Table;  // Avoid a race with Dispose
+            Dictionary<object, object> copyOfTable = _table;  // Avoid a race with Dispose
             if (copyOfTable == null)
                 throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet);
             return copyOfTable.GetEnumerator();
@@ -271,13 +227,7 @@ namespace System.Resources
             while (en.MoveNext())
             {
                 Object value = en.Value;
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-                if (Assembly != null && value is LooselyLinkedResourceReference) {
-                    LooselyLinkedResourceReference assRef = (LooselyLinkedResourceReference) value;
-                    value = assRef.Resolve(Assembly);
-                }
-#endif //LOOSELYLINKEDRESOURCEREFERENCE
-                Table.Add(en.Key, value);
+                _table.Add(en.Key, value);
             }
             // While technically possible to close the Reader here, don't close it
             // to help with some WinRes lifetime issues.
@@ -286,10 +236,10 @@ namespace System.Resources
         private Object GetObjectInternal(String name)
         {
             if (name == null)
-                throw new ArgumentNullException(nameof(name));
+                throw new ArgumentNullException("name");
             Contract.EndContractBlock();
 
-            Hashtable copyOfTable = Table;  // Avoid a race with Dispose
+            Dictionary<object, object> copyOfTable = _table;  // Avoid a race with Dispose
 
             if (copyOfTable == null)
                 throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet);
@@ -299,19 +249,15 @@ namespace System.Resources
 
         private Object GetCaseInsensitiveObjectInternal(String name)
         {
-            Hashtable copyOfTable = Table;  // Avoid a race with Dispose
+            Dictionary<object, object> copyOfTable = _table;  // Avoid a race with Dispose
 
             if (copyOfTable == null)
                 throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet);
 
-            Hashtable caseTable = _caseInsensitiveTable;  // Avoid a race condition with Close
+            Dictionary<object, object> caseTable = _caseInsensitiveTable;  // Avoid a race condition with Close
             if (caseTable == null)
             {
-                caseTable = new Hashtable(StringComparer.OrdinalIgnoreCase);
-#if _DEBUG
-                //Console.WriteLine("ResourceSet::GetObject loading up case-insensitive data");
-                BCLDebug.Perf(false, "Using case-insensitive lookups is bad perf-wise.  Consider capitalizing " + name + " correctly in your source");
-#endif
+                caseTable = new Dictionary<object, object>(CaseInsensitiveStringObjectComparer.Instance);
 
                 IDictionaryEnumerator en = copyOfTable.GetEnumerator();
                 while (en.MoveNext())
@@ -323,5 +269,25 @@ namespace System.Resources
 
             return caseTable[name];
         }
+
+        /// <summary>
+        /// Adapter for StringComparer.OrdinalIgnoreCase to allow it to be used with Dictionary
+        /// </summary>
+        private class CaseInsensitiveStringObjectComparer : IEqualityComparer<object>
+        {
+            public static CaseInsensitiveStringObjectComparer Instance { get; } = new CaseInsensitiveStringObjectComparer();
+
+            private CaseInsensitiveStringObjectComparer() { }
+
+            public new bool Equals(object x, object y)
+            {
+                return ((IEqualityComparer)StringComparer.OrdinalIgnoreCase).Equals(x, y);
+            }
+
+            public int GetHashCode(object obj)
+            {
+                return ((IEqualityComparer)StringComparer.OrdinalIgnoreCase).GetHashCode(obj);
+            }
+        }
     }
 }
 ** 
 ===========================================================*/
 
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Reflection;
+using System.Runtime.Versioning;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+
 namespace System.Resources
 {
-    using System;
-    using System.IO;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Globalization;
-    using System.Reflection;
-    using System.Runtime.Versioning;
-    using System.Diagnostics;
-    using System.Diagnostics.Contracts;
-
     // A RuntimeResourceSet stores all the resources defined in one 
     // particular CultureInfo, with some loading optimizations.
     //
@@ -189,31 +189,18 @@ namespace System.Resources
 
         internal RuntimeResourceSet(String fileName) : base(false)
         {
-            BCLDebug.Log("RESMGRFILEFORMAT", "RuntimeResourceSet .ctor(String)");
             _resCache = new Dictionary<String, ResourceLocator>(FastResourceComparer.Default);
             Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
             _defaultReader = new ResourceReader(stream, _resCache);
             Reader = _defaultReader;
         }
 
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-        internal RuntimeResourceSet(Stream stream, Assembly assembly) : base(false)
-        {
-            BCLDebug.Log("RESMGRFILEFORMAT", "RuntimeResourceSet .ctor(Stream)");
-            _resCache = new Dictionary<String, ResourceLocator>(FastResourceComparer.Default);
-            _defaultReader = new ResourceReader(stream, _resCache);
-            Reader = _defaultReader;
-            Assembly = assembly;
-        }
-#else
         internal RuntimeResourceSet(Stream stream) : base(false)
         {
-            BCLDebug.Log("RESMGRFILEFORMAT", "RuntimeResourceSet .ctor(Stream)");
             _resCache = new Dictionary<String, ResourceLocator>(FastResourceComparer.Default);
             _defaultReader = new ResourceReader(stream, _resCache);
             Reader = _defaultReader;
         }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
 
         protected override void Dispose(bool disposing)
         {
@@ -305,8 +292,6 @@ namespace System.Resources
 
                 if (_defaultReader != null)
                 {
-                    BCLDebug.Log("RESMGRFILEFORMAT", "Going down fast path in RuntimeResourceSet::GetObject");
-
                     // Find the offset within the data section
                     int dataPos = -1;
                     if (_resCache.TryGetValue(key, out resLocation))
@@ -348,13 +333,6 @@ namespace System.Resources
 
                     if (value != null || !ignoreCase)
                     {
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-                        if (Assembly != null && (value is LooselyLinkedResourceReference)) {
-                            LooselyLinkedResourceReference assRef = (LooselyLinkedResourceReference) value;
-                            value = assRef.Resolve(Assembly);
-                        }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
-
                         return value;  // may be null
                     }
                 }  // if (_defaultReader != null)
@@ -369,9 +347,6 @@ namespace System.Resources
                     {
                         _caseInsensitiveTable = new Dictionary<String, ResourceLocator>(StringComparer.OrdinalIgnoreCase);
                     }
-#if _DEBUG
-                    BCLDebug.Perf(!ignoreCase, "Using case-insensitive lookups is bad perf-wise.  Consider capitalizing " + key + " correctly in your source");
-#endif
 
                     if (_defaultReader == null)
                     {
@@ -450,13 +425,7 @@ namespace System.Resources
                     copyOfCache[key] = resLocation;
                 }
             }
-#if LOOSELY_LINKED_RESOURCE_REFERENCE
-            if (Assembly != null && value is LooselyLinkedResourceReference) {
-                LooselyLinkedResourceReference assRef = (LooselyLinkedResourceReference) value;
-                value = assRef.Resolve(Assembly);
-            }
-#endif // LOOSELY_LINKED_RESOURCE_REFERENCE
             return value;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/src/coreclr/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs b/src/coreclr/src/mscorlib/src/Microsoft/Win32/SafeHandles/Win32SafeHandles.cs
deleted file mode 100644 (file)
index 8a7f591..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-// Abstract derivations of SafeHandle designed to provide the common
-// functionality supporting Win32 handles. More specifically, they describe how
-// an invalid handle looks (for instance, some handles use -1 as an invalid
-// handle value, others use 0).
-//
-// Further derivations of these classes can specialise this even further (e.g.
-// file or registry handles).
-// 
-//
-
-using System;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
-
-namespace Microsoft.Win32.SafeHandles
-{
-    // Class of safe handle which uses 0 or -1 as an invalid handle.
-    public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle
-    {
-        protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
-        {
-        }
-
-        // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime
-        protected SafeHandleZeroOrMinusOneIsInvalid()
-        {
-            throw new NotImplementedException();
-        }
-
-        public override bool IsInvalid
-        {
-            get { return handle.IsNull() || handle == new IntPtr(-1); }
-        }
-    }
-
-    // Class of safe handle which uses only -1 as an invalid handle.
-    public abstract class SafeHandleMinusOneIsInvalid : SafeHandle
-    {
-        protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle)
-        {
-        }
-
-        // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime
-        protected SafeHandleMinusOneIsInvalid()
-        {
-            throw new NotImplementedException();
-        }
-
-        public override bool IsInvalid
-        {
-            get { return handle == new IntPtr(-1); }
-        }
-    }
-}