if (resMgrHeaderVersion == ResourceManager.HeaderVersionNumber)
{
br.ReadInt32(); // We don't want the number of bytes to skip.
- readerTypeName = System.CoreLib.FixupCoreLibName(br.ReadString());
- resSetTypeName = System.CoreLib.FixupCoreLibName(br.ReadString());
+ readerTypeName = br.ReadString();
+ resSetTypeName = br.ReadString();
}
else if (resMgrHeaderVersion > ResourceManager.HeaderVersionNumber)
{
int numBytesToSkip = br.ReadInt32();
long endPosition = br.BaseStream.Position + numBytesToSkip;
- readerTypeName = System.CoreLib.FixupCoreLibName(br.ReadString());
- resSetTypeName = System.CoreLib.FixupCoreLibName(br.ReadString());
+ readerTypeName = br.ReadString();
+ resSetTypeName = br.ReadString();
br.BaseStream.Seek(endPosition, SeekOrigin.Begin);
}
}
else
{
- // we do not want to use partial binding here.
- Type readerType = Type.GetType(readerTypeName, true);
+ Type readerType = Type.GetType(readerTypeName, throwOnError: true);
object[] args = new object[1];
args[0] = store;
IResourceReader reader = (IResourceReader)Activator.CreateInstance(readerType, args);
// Ignore the actual version of the ResourceReader and
// RuntimeResourceSet classes. Let those classes deal with
// versioning themselves.
- AssemblyName mscorlib = new AssemblyName(ResourceManager.MscorlibName);
if (readerTypeName != null)
{
- if (!ResourceManager.CompareNames(readerTypeName, ResourceManager.ResReaderTypeName, mscorlib))
+ if (!ResourceManager.IsDefaultType(readerTypeName, ResourceManager.ResReaderTypeName))
return false;
}
if (resSetTypeName != null)
{
- if (!ResourceManager.CompareNames(resSetTypeName, ResourceManager.ResSetTypeName, mscorlib))
+ if (!ResourceManager.IsDefaultType(resSetTypeName, ResourceManager.ResSetTypeName))
return false;
}
// private static CultureInfo _neutralCulture = null;
// This is our min required ResourceSet type.
- private static readonly Type _minResourceSet = typeof(ResourceSet);
+ private static readonly Type s_minResourceSet = typeof(ResourceSet);
// These Strings are used to avoid using Reflection in CreateResourceSet.
- // The first set are used by ResourceWriter. The second are used by
- // InternalResGen.
- internal static readonly string ResReaderTypeName = typeof(ResourceReader).FullName;
- internal static readonly string ResSetTypeName = typeof(RuntimeResourceSet).FullName;
- internal static readonly string MscorlibName = typeof(ResourceReader).Assembly.FullName;
+ internal const string ResReaderTypeName = "System.Resources.ResourceReader";
+ internal const string ResSetTypeName = "System.Resources.RuntimeResourceSet";
internal const string ResFileExtension = ".resources";
internal const int ResFileExtensionLength = 10;
MainAssembly = assembly;
BaseNameField = baseName;
- if (usingResourceSet != null && (usingResourceSet != _minResourceSet) && !(usingResourceSet.IsSubclassOf(_minResourceSet)))
+ if (usingResourceSet != null && (usingResourceSet != s_minResourceSet) && !(usingResourceSet.IsSubclassOf(s_minResourceSet)))
throw new ArgumentException(SR.Arg_ResMgrNotResSet, nameof(usingResourceSet));
_userResourceSet = usingResourceSet;
}
// IGNORES VERSION
- internal static bool CompareNames(string asmTypeName1,
- string typeName2,
- AssemblyName asmName2)
+ internal static bool IsDefaultType(string asmTypeName,
+ string typeName)
{
- Debug.Assert(asmTypeName1 != null, "asmTypeName1 was unexpectedly null");
+ Debug.Assert(asmTypeName != null, "asmTypeName was unexpectedly null");
// First, compare type names
- int comma = asmTypeName1.IndexOf(',');
- if (((comma == -1) ? asmTypeName1.Length : comma) != typeName2.Length)
+ int comma = asmTypeName.IndexOf(',');
+ if (((comma == -1) ? asmTypeName.Length : comma) != typeName.Length)
return false;
// case sensitive
- if (string.Compare(asmTypeName1, 0, typeName2, 0, typeName2.Length, StringComparison.Ordinal) != 0)
+ if (string.Compare(asmTypeName, 0, typeName, 0, typeName.Length, StringComparison.Ordinal) != 0)
return false;
if (comma == -1)
return true;
// Now, compare assembly display names (IGNORES VERSION AND PROCESSORARCHITECTURE)
// also, for mscorlib ignores everything, since that's what the binder is going to do
- while (char.IsWhiteSpace(asmTypeName1[++comma])) ;
+ while (char.IsWhiteSpace(asmTypeName[++comma])) ;
// case insensitive
- AssemblyName an1 = new AssemblyName(asmTypeName1.Substring(comma));
- if (!string.Equals(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase))
- return false;
+ AssemblyName an = new AssemblyName(asmTypeName.Substring(comma));
// to match IsMscorlib() in VM
- if (string.Equals(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase))
- return true;
-
-
- if ((an1.CultureInfo != null) && (asmName2.CultureInfo != null) &&
-#if FEATURE_USE_LCID
- (an1.CultureInfo.LCID != asmName2.CultureInfo.LCID)
-#else
- (an1.CultureInfo.Name != asmName2.CultureInfo.Name)
-#endif
- )
- return false;
-
- byte[] pkt1 = an1.GetPublicKeyToken();
- byte[] pkt2 = asmName2.GetPublicKeyToken();
- if ((pkt1 != null) && (pkt2 != null))
- {
- if (pkt1.Length != pkt2.Length)
- return false;
-
- for (int i = 0; i < pkt1.Length; i++)
- {
- if (pkt1[i] != pkt2[i])
- return false;
- }
- }
-
- return true;
+ return string.Equals(an.Name, "mscorlib", StringComparison.OrdinalIgnoreCase);
}
#if FEATURE_APPX