summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Resources')
-rw-r--r--src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs36
-rw-r--r--src/mscorlib/src/System/Resources/IResourceReader.cs1
-rw-r--r--src/mscorlib/src/System/Resources/IResourceWriter.cs45
-rw-r--r--src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs1
-rw-r--r--src/mscorlib/src/System/Resources/MissingManifestResourceException.cs1
-rw-r--r--src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs1
-rw-r--r--src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Resources/ResourceManager.cs47
-rw-r--r--src/mscorlib/src/System/Resources/ResourceReader.cs251
-rw-r--r--src/mscorlib/src/System/Resources/ResourceSet.cs4
-rw-r--r--src/mscorlib/src/System/Resources/SatelliteContractVersionAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Resources/UltimateResourceFallbackLocation.cs1
12 files changed, 20 insertions, 370 deletions
diff --git a/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs
index 76bf000..c5e9216 100644
--- a/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs
+++ b/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs
@@ -47,36 +47,28 @@ namespace System.Resources {
ResourceSet rs = null;
// Don't use Assembly manifest, but grovel on disk for a file.
- try
- {
- new System.Security.Permissions.FileIOPermission(System.Security.Permissions.PermissionState.Unrestricted).Assert();
- // Create new ResourceSet, if a file exists on disk for it.
- String tempFileName = _mediator.GetResourceFileName(culture);
- fileName = FindResourceFile(culture, tempFileName);
- if (fileName == null)
+ // Create new ResourceSet, if a file exists on disk for it.
+ String tempFileName = _mediator.GetResourceFileName(culture);
+ fileName = FindResourceFile(culture, tempFileName);
+ if (fileName == null)
+ {
+ if (tryParents)
{
- if (tryParents)
+ // If we've hit top of the Culture tree, return.
+ if (culture.HasInvariantCultureName)
{
- // If we've hit top of the Culture tree, return.
- if (culture.HasInvariantCultureName)
- {
- // We really don't think this should happen - we always
- // expect the neutral locale's resources to be present.
- throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoNeutralDisk") + Environment.NewLine + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "<null>" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture));
- }
+ // We really don't think this should happen - we always
+ // expect the neutral locale's resources to be present.
+ throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoNeutralDisk") + Environment.NewLine + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "<null>" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture));
}
}
- else
- {
- rs = CreateResourceSet(fileName);
- }
- return rs;
}
- finally
+ else
{
- System.Security.CodeAccessPermission.RevertAssert();
+ rs = CreateResourceSet(fileName);
}
+ return rs;
}
// Given a CultureInfo, it generates the path &; file name for
diff --git a/src/mscorlib/src/System/Resources/IResourceReader.cs b/src/mscorlib/src/System/Resources/IResourceReader.cs
index 7ab25ec..de8f9db 100644
--- a/src/mscorlib/src/System/Resources/IResourceReader.cs
+++ b/src/mscorlib/src/System/Resources/IResourceReader.cs
@@ -17,7 +17,6 @@ namespace System.Resources {
using System.IO;
using System.Collections;
- [System.Runtime.InteropServices.ComVisible(true)]
public interface IResourceReader : IEnumerable, IDisposable
{
// Interface does not need to be marked with the serializable attribute
diff --git a/src/mscorlib/src/System/Resources/IResourceWriter.cs b/src/mscorlib/src/System/Resources/IResourceWriter.cs
deleted file mode 100644
index ae41b84..0000000
--- a/src/mscorlib/src/System/Resources/IResourceWriter.cs
+++ /dev/null
@@ -1,45 +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.
-
-/*============================================================
-**
-**
-**
-**
-**
-** Purpose: Default way to write strings to a COM+ resource
-** file.
-**
-**
-===========================================================*/
-namespace System.Resources {
- using System;
- using System.IO;
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface IResourceWriter : IDisposable
- {
- // Interface does not need to be marked with the serializable attribute
- // Adds a string resource to the list of resources to be written to a file.
- // They aren't written until WriteFile() is called.
- //
- void AddResource(String name, String value);
-
- // Adds a resource to the list of resources to be written to a file.
- // They aren't written until WriteFile() is called.
- //
- void AddResource(String name, Object value);
-
- // Adds a named byte array as a resource to the list of resources to
- // be written to a file. They aren't written until WriteFile() is called.
- //
- void AddResource(String name, byte[] value);
-
- // Closes the underlying resource file.
- void Close();
-
- // After calling AddResource, this writes all resources to the output
- // stream. This does NOT close the output stream.
- void Generate();
- }
-}
diff --git a/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs b/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs
index 15a076b..9287ae4 100644
--- a/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs
+++ b/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs
@@ -28,7 +28,6 @@ namespace System.Resources {
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public struct LooselyLinkedResourceReference {
private String _manifestResourceName;
private String _typeName;
diff --git a/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs b/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs
index e616bfe..2e82f19 100644
--- a/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs
+++ b/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs
@@ -18,7 +18,6 @@ using System.Runtime.Serialization;
namespace System.Resources {
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class MissingManifestResourceException : SystemException
{
public MissingManifestResourceException()
diff --git a/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs b/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs
index 3d59f85..fc676a8 100644
--- a/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs
+++ b/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs
@@ -20,7 +20,6 @@ using System.Runtime.Serialization;
namespace System.Resources {
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class MissingSatelliteAssemblyException : SystemException
{
private String _cultureName;
diff --git a/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs b/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs
index 6517a56..a2ed6fb 100644
--- a/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs
+++ b/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs
@@ -26,7 +26,6 @@ namespace System.Resources {
using System.Diagnostics.Contracts;
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=false)]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class NeutralResourcesLanguageAttribute : Attribute
{
private String _culture;
diff --git a/src/mscorlib/src/System/Resources/ResourceManager.cs b/src/mscorlib/src/System/Resources/ResourceManager.cs
index 15f6af7..f17a7c8 100644
--- a/src/mscorlib/src/System/Resources/ResourceManager.cs
+++ b/src/mscorlib/src/System/Resources/ResourceManager.cs
@@ -23,7 +23,6 @@ namespace System.Resources {
using System.Reflection;
using System.Runtime.Serialization;
using System.Security;
- using System.Security.Permissions;
using System.Threading;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
@@ -149,7 +148,6 @@ namespace System.Resources {
//
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class ResourceManager
{
@@ -162,7 +160,7 @@ namespace System.Resources {
// Sets is a many-to-one table of CultureInfos mapped to ResourceSets.
// Don't synchronize ResourceSets - too fine-grained a lock to be effective
[Obsolete("call InternalGetResourceSet instead")]
- protected Hashtable ResourceSets;
+ internal Hashtable ResourceSets;
// don't serialize the cache of ResourceSets
@@ -738,48 +736,9 @@ namespace System.Resources {
}
Contract.EndContractBlock();
-#if !FEATURE_WINDOWSPHONE
- String v = null;
- if (a.ReflectionOnly) {
- foreach (CustomAttributeData data in CustomAttributeData.GetCustomAttributes(a)) {
- if (data.Constructor.DeclaringType == typeof(SatelliteContractVersionAttribute)) {
- v = (String)data.ConstructorArguments[0].Value;
- break;
- }
- }
-
- if (v == null)
- return null;
- }
- else {
- Object[] attrs = a.GetCustomAttributes(typeof(SatelliteContractVersionAttribute), false);
- if (attrs.Length == 0)
- return null;
- Debug.Assert(attrs.Length == 1, "Cannot have multiple instances of SatelliteContractVersionAttribute on an assembly!");
- v = ((SatelliteContractVersionAttribute)attrs[0]).Version;
- }
- Version ver;
- try {
- ver = new Version(v);
- }
- catch(ArgumentOutOfRangeException e) {
- // Note we are prone to hitting infinite loops if mscorlib's
- // SatelliteContractVersionAttribute contains bogus values.
- // If this assert fires, please fix the build process for the
- // BCL directory.
- if (a == typeof(Object).Assembly) {
- Debug.Assert(false, System.CoreLib.Name+"'s SatelliteContractVersionAttribute is a malformed version string!");
- return null;
- }
-
- throw new ArgumentException(Environment.GetResourceString("Arg_InvalidSatelliteContract_Asm_Ver", a.ToString(), v), e);
- }
- return ver;
-#else
- // On the phone return null. The calling code will use the assembly version instead to avoid potential type
+ // Return null. The calling code will use the assembly version instead to avoid potential type
// and library loads caused by CA lookup. NetCF uses the assembly version always.
return null;
-#endif
}
protected static CultureInfo GetNeutralResourcesLanguage(Assembly a)
@@ -1285,12 +1244,10 @@ namespace System.Resources {
return null;
}
- [ComVisible(false)]
public UnmanagedMemoryStream GetStream(String name) {
return GetStream(name, (CultureInfo)null);
}
- [ComVisible(false)]
public UnmanagedMemoryStream GetStream(String name, CultureInfo culture) {
Object obj = GetObject(name, culture, false);
UnmanagedMemoryStream ums = obj as UnmanagedMemoryStream;
diff --git a/src/mscorlib/src/System/Resources/ResourceReader.cs b/src/mscorlib/src/System/Resources/ResourceReader.cs
index 89cfdb1..d752771 100644
--- a/src/mscorlib/src/System/Resources/ResourceReader.cs
+++ b/src/mscorlib/src/System/Resources/ResourceReader.cs
@@ -20,13 +20,7 @@ namespace System.Resources {
using System.Text;
using System.Collections;
using System.Collections.Generic;
-#if FEATURE_SERIALIZATION
- using System.Runtime.Serialization;
- using System.Runtime.Serialization.Formatters;
- using System.Runtime.Serialization.Formatters.Binary;
-#endif // FEATURE_SERIALIZATION
using System.Reflection;
- using System.Security.Permissions;
using System.Security;
using System.Globalization;
using System.Configuration.Assemblies;
@@ -73,7 +67,6 @@ namespace System.Resources {
}
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ResourceReader : IResourceReader
{
// A reasonable default buffer size for reading from files, especially
@@ -100,9 +93,6 @@ namespace System.Resources {
private unsafe int* _namePositionsPtr; // If we're using UnmanagedMemoryStream
private RuntimeType[] _typeTable; // Lazy array of Types for resource values.
private int[] _typeNamePositions; // To delay initialize type table
-#if FEATURE_SERIALIZATION
- private BinaryFormatter _objFormatter; // Deserialization stuff.
-#endif // FEATURE_SERIALIZATION
private int _numResources; // Num of resources files, in case arrays aren't allocated.
// We'll include a separate code path that uses UnmanagedMemoryStream to
@@ -116,45 +106,11 @@ namespace System.Resources {
private bool _debug; // Whether this file has debugging stuff in it.
#endif
-#if FEATURE_SERIALIZATION
- private bool[] _safeToDeserialize; // Whether to assert serialization permission
- private TypeLimitingDeserializationBinder _typeLimitingBinder;
-
- // One of our goals is to make sure localizable Windows Forms apps
- // work in semi-trusted scenarios (ie, without serialization permission).
- // Unfortunate we're serializing out some complex types that currently
- // require a security check on deserialization. We may fix this
- // in a next version, but for now just hard-code a list.
- // Hard-code in the assembly name (minus version) so people can't spoof us.
- private static readonly String[] TypesSafeForDeserialization = {
- "System.String[], mscorlib, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.DateTime[], mscorlib, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Bitmap, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Imaging.Metafile, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Point, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.PointF, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Size, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.SizeF, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Font, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Icon, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Drawing.Color, System.Drawing, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
- "System.Windows.Forms.Cursor, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.Padding, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.LinkArea, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.ImageListStreamer, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.ListViewGroup, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.ListViewItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.ListViewItem+ListViewSubItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.ListViewItem+ListViewSubItem+SubItemStyle, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.OwnerDrawPropertyBag, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken,
- "System.Windows.Forms.TreeNode, System.Windows.Forms, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken
- };
-#endif // FEATURE_SERIALIZATION
public ResourceReader(String fileName)
{
_resCache = new Dictionary<String, ResourceLocator>(FastResourceComparer.Default);
- _store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess, Path.GetFileName(fileName), false), Encoding.UTF8);
+ _store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess), Encoding.UTF8);
BCLDebug.Log("RESMGRFILEFORMAT", "ResourceReader .ctor(String). UnmanagedMemoryStream: "+(_ums!=null));
try {
@@ -240,10 +196,6 @@ namespace System.Resources {
// Unaligned, little endian format
return buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
}
-
- private void SkipInt32() {
- _store.BaseStream.Seek(4, SeekOrigin.Current);
- }
private void SkipString() {
@@ -580,8 +532,6 @@ namespace System.Resources {
}
}
-#if FEATURE_SERIALIZATION
-#endif
private Object _LoadObjectV1(int pos) {
_store.BaseStream.Seek(_dataSectionOffset+pos, SeekOrigin.Begin);
int typeIndex = _store.Read7BitEncodedInt();
@@ -629,11 +579,7 @@ namespace System.Resources {
return new Decimal(bits);
}
else {
-#if FEATURE_SERIALIZATION
- return DeserializeObject(typeIndex);
-#else
throw new NotSupportedException(Environment.GetResourceString("NotSupported_ResourceObjectSerialization"));
-#endif // FEATURE_SERIALIZATION
}
}
@@ -759,7 +705,7 @@ namespace System.Resources {
// For the case that we've memory mapped in the .resources
// file, just return a Stream pointing to that block of memory.
unsafe {
- return new UnmanagedMemoryStream(_ums.PositionPointer, len, len, FileAccess.Read, true);
+ return new UnmanagedMemoryStream(_ums.PositionPointer, len, len, FileAccess.Read);
}
}
@@ -771,57 +717,10 @@ namespace System.Resources {
}
// Normal serialized objects
-#if FEATURE_SERIALIZATION
- int typeIndex = typeCode - ResourceTypeCode.StartOfUserTypes;
- return DeserializeObject(typeIndex);
-#else
throw new NotSupportedException(Environment.GetResourceString("NotSupported_ResourceObjectSerialization"));
-#endif // FEATURE_SERIALIZATION
}
-#if FEATURE_SERIALIZATION
- // Helper method to safely deserialize a type, using a type-limiting
- // deserialization binder to simulate a type-limiting deserializer.
- // This method handles types that are safe to deserialize, as well as
- // ensuring we only get back what we expect.
- private Object DeserializeObject(int typeIndex)
- {
- RuntimeType type = FindType(typeIndex);
- // Initialize deserialization permission array, if needed
- if (_safeToDeserialize == null)
- InitSafeToDeserializeArray();
-
- // Ensure that the object we deserialized is exactly the same
- // type of object we thought we should be deserializing. This
- // will help prevent malformed .resources files from using our
- // serialization permission assert to deserialize anything
- // via a malformed type ID.
-
- Object graph;
- if (_safeToDeserialize[typeIndex]) {
- // Don't assert serialization permission - just ask the binary
- // formatter to avoid a permission check. This ensures that any
- // types which do demand serialization permission in their
- // deserialization .cctors will fail.
- // Also, use a serialization binder to limit bind requests to
- // our allowed list of WinForms types.
- _objFormatter.Binder = _typeLimitingBinder;
- _typeLimitingBinder.ExpectingToDeserialize(type);
- graph = _objFormatter.UnsafeDeserialize(_store.BaseStream, null);
- }
- else {
- _objFormatter.Binder = null;
- graph = _objFormatter.Deserialize(_store.BaseStream);
- }
-
- // This check is about correctness, not security at this point.
- if (graph.GetType() != type)
- throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResType&SerBlobMismatch", type.FullName, graph.GetType().FullName));
-
- return graph;
- }
-#endif // FEATURE_SERIALIZATION
// Reads in the header information for a .resources file. Verifies some
// of the assumptions about this resource set, and builds the class table
@@ -829,12 +728,6 @@ namespace System.Resources {
private void ReadResources()
{
Debug.Assert(_store != null, "ResourceReader is closed!");
-#if FEATURE_SERIALIZATION
- BinaryFormatter bf = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.File | StreamingContextStates.Persistence));
- _typeLimitingBinder = new TypeLimitingDeserializationBinder();
- bf.Binder = _typeLimitingBinder;
- _objFormatter = bf;
-#endif // FEATURE_SERIALIZATION
try {
// mega try-catch performs exceptionally bad on x64; factored out body into
@@ -918,7 +811,7 @@ namespace System.Resources {
throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
}
BCLDebug.Log("RESMGRFILEFORMAT", "ReadResources: Expecting " + _numResources + " resources.");
-#if _DEBUG
+#if RESOURCE_FILE_FORMAT_DEBUG
if (ResourceManager.DEBUG >= 4)
Console.WriteLine("ResourceReader::ReadResources - Reading in "+_numResources+" resources");
#endif
@@ -938,7 +831,7 @@ namespace System.Resources {
SkipString();
}
-#if _DEBUG
+#if RESOURCE_FILE_FORMAT_DEBUG
if (ResourceManager.DEBUG >= 5)
Console.WriteLine("ResourceReader::ReadResources - Reading in "+numTypes+" type table entries");
#endif
@@ -1049,7 +942,6 @@ namespace System.Resources {
String typeName = _store.ReadString();
_typeTable[typeIndex] = (RuntimeType)Type.GetType(typeName, true);
}
-#if !FEATURE_SERIALIZATION
// If serialization isn't supported, we convert FileNotFoundException to
// NotSupportedException for consistency with v2. This is a corner-case, but the
// idea is that we want to give the user a more accurate error message. Even if
@@ -1064,7 +956,6 @@ namespace System.Resources {
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_ResourceObjectSerialization"));
}
-#endif // FEATURE_SERIALIZATION
finally {
_store.BaseStream.Position = oldPos;
}
@@ -1073,74 +964,6 @@ namespace System.Resources {
return _typeTable[typeIndex];
}
-#if FEATURE_SERIALIZATION
- private void InitSafeToDeserializeArray()
- {
- _safeToDeserialize = new bool[_typeTable.Length];
- for(int i=0; i<_typeTable.Length; i++) {
- long oldPos = _store.BaseStream.Position;
- String typeName;
- try {
- _store.BaseStream.Position = _typeNamePositions[i];
- typeName = _store.ReadString();
- }
- finally {
- _store.BaseStream.Position = oldPos;
- }
-
- AssemblyName an;
- String typePart;
- RuntimeType resourceType = (RuntimeType)Type.GetType(typeName, false);
- if (resourceType == null) {
- an = null;
- typePart = typeName;
- }
- else {
- // Enums should be safe to deserialize, and this helps out
- // partially trusted, localized WinForms apps.
- if (resourceType.BaseType == typeof(Enum)) {
- _safeToDeserialize[i] = true;
- continue;
- }
-
- // For most types, check our TypesSafeForDeserialization.
- typePart = resourceType.FullName;
-
- an = new AssemblyName();
-
- // resourceType is retrieved via Type.GetType and must be a RuntimeType
- RuntimeAssembly a = (RuntimeAssembly)resourceType.Assembly;
- an.Init(a.GetSimpleName(),
- a.GetPublicKey(),
- null, // public key token
- null, // version
- a.GetLocale(),
- AssemblyHashAlgorithm.None,
- AssemblyVersionCompatibility.SameMachine,
- null, // codebase
- AssemblyNameFlags.PublicKey,
- null); // strong name key pair
- }
-
- foreach(String safeType in TypesSafeForDeserialization) {
- if (ResourceManager.CompareNames(safeType, typePart, an)) {
-#if _DEBUG
- if (ResourceManager.DEBUG >= 7)
- Console.WriteLine("ResReader: Found a type-safe type to deserialize! Type name: {0}", typeName);
-#endif
- _safeToDeserialize[i] = true;
- continue;
- }
- }
-
-#if _DEBUG
- if (ResourceManager.DEBUG >= 7)
- if (!_safeToDeserialize[i])
- Console.WriteLine("ResReader: Found a type that wasn't safe to deserialize: {0}", typeName);
-#endif
- }
- }
-#endif // FEATURE_SERIALIZATION
public void GetResourceData(String resourceName, out String resourceType, out byte[] resourceData)
{
@@ -1224,72 +1047,6 @@ namespace System.Resources {
}
}
-#if FEATURE_SERIALIZATION
- // We need to build a type-limiting deserializer. We know exactly which
- // type we want to deserialize, and if someone tells us we have type X
- // (which might be safe to deserialize) and they give us a serialized
- // form of type Y, we don't want to run the deserialization constructor
- // because we've asserted serialization formatter permission. Instead,
- // limit the binary formatter's type binding to precisely the type we
- // expect. If they ever don't match, that's a corrupt .resources file.
- // We also must check the complete object graph to ensure all of the
- // graph contains safe objects.
- // Note this is tightly coupled to the BinaryFormatter, since we use
- // its internal ObjectReader::FastBindToType method, and we had to
- // change the ObjectReader to register itself with this type.
- internal sealed class TypeLimitingDeserializationBinder : SerializationBinder
- {
- private RuntimeType _typeToDeserialize;
- // This is tightly coupled with the binary formatter, because we
- // want to use exactly the same code found in the ObjectReader
- // to do the lookup, then just give a thumbs up or down based on
- // a type equality comparison. In the future, we could consider
- // some better refactoring of this code.
- private ObjectReader _objectReader;
-
- internal ObjectReader ObjectReader {
- get { return _objectReader; }
- set { _objectReader = value; }
- }
-
- internal void ExpectingToDeserialize(RuntimeType type)
- {
- _typeToDeserialize = type;
- }
-
- public override Type BindToType(string assemblyName, string typeName)
- {
- // BinaryObjectReader::Bind tries us first, then its own code.
- // Returning null means let the default binding rules happen.
- AssemblyName an = new AssemblyName(assemblyName);
-
- bool safe = false;
- foreach(String safeType in TypesSafeForDeserialization) {
- if (ResourceManager.CompareNames(safeType, typeName, an)) {
- safe = true;
- break;
- }
- }
-
- // WinForms types may internally use some enums that aren't
- // on our safe to deserialize list, like Font using FontStyle.
- Type t = ObjectReader.FastBindToType(assemblyName, typeName);
- if (t.IsEnum)
- safe = true;
-
- if (safe)
- return null;
-
- // Throw instead of returning null.
- // If you're looking at this in a debugger, you've either
- // got a malformed .resources file on your hands, or WinForms
- // types have taken a new dependency on another type. Check
- // whether assemblyName & typeName refer to a trustworthy type,
- // & consider adding it to the TypesSafeToDeserialize list.
- throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResType&SerBlobMismatch", _typeToDeserialize.FullName, typeName));
- }
- }
-#endif // FEATURE_SERIALIZATION
internal sealed class ResourceEnumerator : IDictionaryEnumerator
diff --git a/src/mscorlib/src/System/Resources/ResourceSet.cs b/src/mscorlib/src/System/Resources/ResourceSet.cs
index 1b272fc..8fd9346 100644
--- a/src/mscorlib/src/System/Resources/ResourceSet.cs
+++ b/src/mscorlib/src/System/Resources/ResourceSet.cs
@@ -17,7 +17,6 @@ namespace System.Resources {
using System.Collections;
using System.IO;
using System.Globalization;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Runtime.Serialization;
@@ -31,7 +30,6 @@ namespace System.Resources {
// stores them in a hash table. Custom IResourceReaders can be used.
//
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class ResourceSet : IDisposable, IEnumerable
{
[NonSerialized] protected IResourceReader Reader;
@@ -158,7 +156,6 @@ namespace System.Resources {
#if LOOSELY_LINKED_RESOURCE_REFERENCE
// Optional - used for resolving assembly manifest resource references.
// This can safely be null.
- [ComVisible(false)]
public Assembly Assembly {
get { return _assembly; }
/*protected*/ set { _assembly = value; }
@@ -181,7 +178,6 @@ namespace System.Resources {
return Type.GetType("System.Resources.ResourceWriter, System.Resources.Writer, Version=4.0.1.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken, throwOnError: true);
}
- [ComVisible(false)]
public virtual IDictionaryEnumerator GetEnumerator()
{
return GetEnumeratorHelper();
diff --git a/src/mscorlib/src/System/Resources/SatelliteContractVersionAttribute.cs b/src/mscorlib/src/System/Resources/SatelliteContractVersionAttribute.cs
index 3272790..86e972e 100644
--- a/src/mscorlib/src/System/Resources/SatelliteContractVersionAttribute.cs
+++ b/src/mscorlib/src/System/Resources/SatelliteContractVersionAttribute.cs
@@ -19,7 +19,6 @@ namespace System.Resources {
using System.Diagnostics.Contracts;
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SatelliteContractVersionAttribute : Attribute
{
private String _version;
diff --git a/src/mscorlib/src/System/Resources/UltimateResourceFallbackLocation.cs b/src/mscorlib/src/System/Resources/UltimateResourceFallbackLocation.cs
index 5785bfd..aa4069a 100644
--- a/src/mscorlib/src/System/Resources/UltimateResourceFallbackLocation.cs
+++ b/src/mscorlib/src/System/Resources/UltimateResourceFallbackLocation.cs
@@ -20,7 +20,6 @@ using System;
namespace System.Resources {
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum UltimateResourceFallbackLocation
{
MainAssembly,