Skip to content

Commit

Permalink
System.Private.CoreLib: Move ResoureReader/ResourceSet to shared. (do…
Browse files Browse the repository at this point in the history
…tnet#19994)

* Move ResoureReader/ResourceSet to shared.

* Remove unnecessary cast to RuntimeType from ResoureReader.
  • Loading branch information
filipnavara authored and jkotas committed Sep 16, 2018
1 parent e8ad788 commit 3743d9a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/System.Private.CoreLib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@
<Compile Include="$(BclSourcesRoot)\System\Resources\IResourceGroveler.cs" />
<Compile Include="$(BclSourcesRoot)\System\Resources\ManifestBasedResourceGroveler.cs" />
<Compile Include="$(BclSourcesRoot)\System\Resources\ResourceManager.cs" />
<Compile Include="$(BclSourcesRoot)\System\Resources\ResourceReader.cs" />
<Compile Include="$(BclSourcesRoot)\System\Resources\ResourceSet.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\Collections\Generic\Comparer.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@
<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\ResourceReader.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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public sealed class ResourceReader : IResourceReader
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.

Expand Down Expand Up @@ -547,7 +547,7 @@ private object _LoadObjectV1(int pos)
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.
Expand Down Expand Up @@ -827,7 +827,7 @@ private void _ReadResources()
{
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++)
{
Expand Down Expand Up @@ -931,7 +931,7 @@ private void _ReadResources()
// 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)
{
Expand All @@ -944,7 +944,7 @@ private RuntimeType FindType(int typeIndex)
{
_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
Expand Down

0 comments on commit 3743d9a

Please sign in to comment.