From 567c60e5ad153837b1bb6b6ac509873342055c52 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 16 Sep 2018 05:51:28 +0200 Subject: [PATCH] System.Private.CoreLib: Move ResoureReader/ResourceSet to shared. (dotnet/coreclr#19994) * Move ResoureReader/ResourceSet to shared. * Remove unnecessary cast to RuntimeType from ResoureReader. Commit migrated from https://github.com/dotnet/coreclr/commit/3743d9a7d5959383ae4c31b4d9273fb61e2fb389 --- .../src/System.Private.CoreLib/System.Private.CoreLib.csproj | 2 -- .../src/System.Private.CoreLib.Shared.projitems | 2 ++ .../src/System/Resources/ResourceReader.cs | 10 +++++----- .../System.Private.CoreLib/src/System/Resources/ResourceSet.cs | 0 4 files changed, 7 insertions(+), 7 deletions(-) rename src/{coreclr/src => libraries}/System.Private.CoreLib/src/System/Resources/ResourceReader.cs (99%) rename src/{coreclr/src => libraries}/System.Private.CoreLib/src/System/Resources/ResourceSet.cs (100%) diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index 74f04d8..c4f3fc7 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -476,8 +476,6 @@ - - diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 769b216..af1b99a 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -403,6 +403,8 @@ + + diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs similarity index 99% rename from src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs rename to src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs index 70e655f..cd2b0d0 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs @@ -94,7 +94,7 @@ namespace System.Resources private unsafe int* _nameHashesPtr; // In case we're using UnmanagedMemoryStream private int[] _namePositions; // relative locations of names private unsafe int* _namePositionsPtr; // If we're using UnmanagedMemoryStream - private RuntimeType[] _typeTable; // Lazy array of Types for resource values. + private Type[] _typeTable; // Lazy array of Types for resource values. private int[] _typeNamePositions; // To delay initialize type table private int _numResources; // Num of resources files, in case arrays aren't allocated. @@ -547,7 +547,7 @@ namespace System.Resources int typeIndex = _store.Read7BitEncodedInt(); if (typeIndex == -1) return null; - RuntimeType type = FindType(typeIndex); + Type type = FindType(typeIndex); // Consider putting in logic to see if this type is a // primitive or a value type first, so we can reach the // deserialization code faster for arbitrary objects. @@ -827,7 +827,7 @@ namespace System.Resources { throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } - _typeTable = new RuntimeType[numTypes]; + _typeTable = new Type[numTypes]; _typeNamePositions = new int[numTypes]; for (int i = 0; i < numTypes; i++) { @@ -931,7 +931,7 @@ namespace System.Resources // This allows us to delay-initialize the Type[]. This might be a // good startup time savings, since we might have to load assemblies // and initialize Reflection. - private RuntimeType FindType(int typeIndex) + private Type FindType(int typeIndex) { if (typeIndex < 0 || typeIndex >= _typeTable.Length) { @@ -944,7 +944,7 @@ namespace System.Resources { _store.BaseStream.Position = _typeNamePositions[typeIndex]; string typeName = _store.ReadString(); - _typeTable[typeIndex] = (RuntimeType)Type.GetType(typeName, true); + _typeTable[typeIndex] = Type.GetType(typeName, true); } // If serialization isn't supported, we convert FileNotFoundException to // NotSupportedException for consistency with v2. This is a corner-case, but the diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceSet.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs similarity index 100% rename from src/coreclr/src/System.Private.CoreLib/src/System/Resources/ResourceSet.cs rename to src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs -- 2.7.4