Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 94fef02

Browse files
committed
Merge pull request #2130 from nguerrera/metadata-resources
Switch S.R.Metadata to standard Strings.resx pattern
2 parents 9c73cba + 61d6743 commit 94fef02

20 files changed

+68
-694
lines changed

src/System.Reflection.Metadata/src/Resources/MetadataResources.Designer.cs

Lines changed: 0 additions & 613 deletions
This file was deleted.

src/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
</PropertyGroup>
3939
<ItemGroup>
4040
<Compile Include="Properties\InternalsVisibleTo.cs" />
41-
<Compile Include="Resources\MetadataResources.Designer.cs">
42-
<AutoGen>True</AutoGen>
43-
<DesignTime>True</DesignTime>
44-
<DependentUpon>MetadataResources.resx</DependentUpon>
45-
</Compile>
4641
<Compile Include="System\Reflection\Internal\MemoryBlocks\AbstractMemoryBlock.cs" />
4742
<Compile Include="System\Reflection\Internal\MemoryBlocks\ByteArrayMemoryBlock.cs" />
4843
<Compile Include="System\Reflection\Internal\MemoryBlocks\ByteArrayMemoryProvider.cs" />
@@ -166,14 +161,6 @@
166161
<Compile Include="System\Reflection\PortableExecutable\SectionHeader.cs" />
167162
<Compile Include="System\Reflection\System.Reflection.cs" />
168163
</ItemGroup>
169-
<ItemGroup>
170-
<EmbeddedResource Include="Resources\MetadataResources.resx">
171-
<Generator>ResXFileCodeGenerator</Generator>
172-
<SubType>Designer</SubType>
173-
<LastGenOutput>MetadataResources.Designer.cs</LastGenOutput>
174-
<CustomToolNamespace>System.Reflection.Metadata</CustomToolNamespace>
175-
</EmbeddedResource>
176-
</ItemGroup>
177164
<ItemGroup>
178165
<Reference Include="System.Collections.Immutable, Version=1.1.34.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
179166
<HintPath>$(PackagesDir)\System.Collections.Immutable.1.1.34-rc\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>

src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/MemoryBlock.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ private void CheckBounds(int offset, int byteCount)
3535
[MethodImpl(MethodImplOptions.NoInlining)]
3636
private static void ThrowOutOfBounds()
3737
{
38-
throw new BadImageFormatException(MetadataResources.OutOfBoundsRead);
38+
throw new BadImageFormatException(SR.OutOfBoundsRead);
3939
}
4040

4141
[MethodImpl(MethodImplOptions.NoInlining)]
4242
private static void ThrowReferenceOverflow()
4343
{
44-
throw new BadImageFormatException(MetadataResources.RowIdOrHeapOffsetTooLarge);
44+
throw new BadImageFormatException(SR.RowIdOrHeapOffsetTooLarge);
4545
}
4646

4747
internal byte[] ToArray()

src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/StreamExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal static unsafe void CopyTo(this Stream source, byte* destination, int si
2929

3030
if (bytesRead <= 0 || bytesRead > readSize)
3131
{
32-
throw new IOException(MetadataResources.UnexpectedStreamEnd);
32+
throw new IOException(SR.UnexpectedStreamEnd);
3333
}
3434

3535
Marshal.Copy(buffer, 0, (IntPtr)destination, bytesRead);

src/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public unsafe BlobReader(byte* buffer, int length)
3838
// the reader performs little-endian specific operations
3939
if (!BitConverter.IsLittleEndian)
4040
{
41-
throw new PlatformNotSupportedException(MetadataResources.LitteEndianArchitectureRequired);
41+
throw new PlatformNotSupportedException(SR.LitteEndianArchitectureRequired);
4242
}
4343

4444
this = new BlobReader(new MemoryBlock(buffer, length));
@@ -163,7 +163,7 @@ internal MemoryBlock GetMemoryBlockAt(int offset, int length)
163163
[MethodImpl(MethodImplOptions.NoInlining)]
164164
private static void ThrowOutOfBounds()
165165
{
166-
throw new BadImageFormatException(MetadataResources.OutOfBoundsRead);
166+
throw new BadImageFormatException(SR.OutOfBoundsRead);
167167
}
168168

169169
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -423,13 +423,13 @@ public int ReadCompressedSignedInteger()
423423
[MethodImpl(MethodImplOptions.NoInlining)]
424424
private static void ThrowInvalidCompressedInteger()
425425
{
426-
throw new BadImageFormatException(MetadataResources.InvalidCompressedInteger);
426+
throw new BadImageFormatException(SR.InvalidCompressedInteger);
427427
}
428428

429429
[MethodImpl(MethodImplOptions.NoInlining)]
430430
private static void ThrowInvalidSerializedString()
431431
{
432-
throw new BadImageFormatException(MetadataResources.InvalidSerializedString);
432+
throw new BadImageFormatException(SR.InvalidSerializedString);
433433
}
434434

435435
/// <summary>

src/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/MetadataTokens.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ private static int MapVirtualHandleRowId(MetadataReader reader, Handle handle)
9191
case HandleKind.Blob:
9292
// We could precalculate offsets for virtual strings and blobs as we are creating them
9393
// if we wanted to implement this.
94-
throw new NotSupportedException(MetadataResources.CantGetOffsetForVirtualHeapHandle);
94+
throw new NotSupportedException(SR.CantGetOffsetForVirtualHeapHandle);
9595

9696
default:
97-
throw new ArgumentException(MetadataResources.InvalidHandle, "handle");
97+
throw new ArgumentException(SR.InvalidHandle, "handle");
9898
}
9999
}
100100

@@ -401,25 +401,25 @@ public static GuidHandle GuidHandle(int offset)
401401
[MethodImpl(MethodImplOptions.NoInlining)]
402402
private static void ThrowEntityHandleRequired()
403403
{
404-
throw new ArgumentException(MetadataResources.NotMetadataTableHandle, "handle");
404+
throw new ArgumentException(SR.NotMetadataTableHandle, "handle");
405405
}
406406

407407
[MethodImpl(MethodImplOptions.NoInlining)]
408408
private static void ThrowHeapHandleRequired()
409409
{
410-
throw new ArgumentException(MetadataResources.NotMetadataHeapHandle, "handle");
410+
throw new ArgumentException(SR.NotMetadataHeapHandle, "handle");
411411
}
412412

413413
[MethodImpl(MethodImplOptions.NoInlining)]
414414
private static void ThrowEntityOrUserStringHandleRequired()
415415
{
416-
throw new ArgumentException(MetadataResources.NotMetadataTableOrUserStringHandle, "handle");
416+
throw new ArgumentException(SR.NotMetadataTableOrUserStringHandle, "handle");
417417
}
418418

419419
[MethodImpl(MethodImplOptions.NoInlining)]
420420
private static void ThrowInvalidToken()
421421
{
422-
throw new ArgumentException(MetadataResources.InvalidToken, "token");
422+
throw new ArgumentException(SR.InvalidToken, "token");
423423
}
424424

425425
[MethodImpl(MethodImplOptions.NoInlining)]

src/System.Reflection.Metadata/src/System/Reflection/Metadata/Handles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ internal static void ThrowInvalidCast()
191191
[MethodImpl(MethodImplOptions.NoInlining)]
192192
internal static void ThrowInvalidCodedIndex()
193193
{
194-
throw new BadImageFormatException(MetadataResources.InvalidCodedIndex);
194+
throw new BadImageFormatException(SR.InvalidCodedIndex);
195195
}
196196

197197
public static readonly ModuleDefinitionHandle ModuleDefinition = new ModuleDefinitionHandle(1);

src/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/NamespaceCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal NamespaceData GetNamespaceData(NamespaceDefinitionHandle handle)
6060
[MethodImplAttribute(MethodImplOptions.NoInlining)]
6161
private static void ThrowInvalidHandle()
6262
{
63-
throw new BadImageFormatException(MetadataResources.InvalidHandle);
63+
throw new BadImageFormatException(SR.InvalidHandle);
6464
}
6565

6666
/// <summary>

src/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataAggregator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ internal static void CalculateDeltaRowCountsForGeneration(RowCounts[][] rowCount
227227
{
228228
if (rid != tableRowCounts[generation].AggregateInserts + 1)
229229
{
230-
throw new BadImageFormatException(MetadataResources.EnCMapNotSorted);
230+
throw new BadImageFormatException(SR.EnCMapNotSorted);
231231
}
232232

233233
// insert:
@@ -278,7 +278,7 @@ public Handle GetGenerationHandle(Handle handle, out int generation)
278278

279279
if (generation >= sizes.Length)
280280
{
281-
throw new ArgumentException(MetadataResources.HandleBelongsToFutureGeneration, "handle");
281+
throw new ArgumentException(SR.HandleBelongsToFutureGeneration, "handle");
282282
}
283283

284284
// GUID heap accumulates - previous heap is copied to the next generation
@@ -311,7 +311,7 @@ public Handle GetGenerationHandle(Handle handle, out int generation)
311311

312312
if (generation >= sizes.Length)
313313
{
314-
throw new ArgumentException(MetadataResources.HandleBelongsToFutureGeneration, "handle");
314+
throw new ArgumentException(SR.HandleBelongsToFutureGeneration, "handle");
315315
}
316316
}
317317

0 commit comments

Comments
 (0)