Imported Upstream version 4.0.1

Former-commit-id: 757121caeaad523350be5330f0a3ecc891c70fb8
This commit is contained in:
Jo Shields
2015-04-26 19:10:23 +01:00
parent 7fce50ac98
commit c54b0bda4e
252 changed files with 16715 additions and 1176 deletions

View File

@@ -255,9 +255,14 @@ namespace System.Resources {
Contract.Assert(a != null, "assembly != null");
string cultureName = null;
short fallback = 0;
#if MONO
if (GetNeutralResourcesLanguageAttribute(a, ref cultureName, ref fallback)) {
#else
if (GetNeutralResourcesLanguageAttribute(((RuntimeAssembly)a).GetNativeHandle(),
JitHelpers.GetStringHandleOnStack(ref cultureName),
out fallback)) {
#endif
if ((UltimateResourceFallbackLocation)fallback < UltimateResourceFallbackLocation.MainAssembly || (UltimateResourceFallbackLocation)fallback > UltimateResourceFallbackLocation.Satellite) {
throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallback));
}
@@ -718,11 +723,24 @@ namespace System.Resources {
throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoNeutralAsm", resName, _mediator.MainAssembly.GetSimpleName()));
}
#if MONO
static bool GetNeutralResourcesLanguageAttribute (Assembly assembly, ref string cultureName, ref short fallbackLocation)
{
var ca = assembly.GetCustomAttribute<NeutralResourcesLanguageAttribute> ();
if (ca == null)
return false;
cultureName = ca.CultureName;
fallbackLocation = (short) ca.Location;
return true;
}
#else
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[System.Security.SecurityCritical] // Our security team doesn't yet allow safe-critical P/Invoke methods.
[ResourceExposure(ResourceScope.None)]
[System.Security.SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetNeutralResourcesLanguageAttribute(RuntimeAssembly assemblyHandle, StringHandleOnStack cultureName, out short fallbackLocation);
#endif
}
}

View File

@@ -516,9 +516,10 @@ namespace System.Resources {
_neutralResourcesCulture = ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(MainAssembly, ref _fallbackLoc);
#if !FEATURE_CORECLR && !MONO // PAL doesn't support eventing, and we don't compile event providers for coreclr
#if !FEATURE_CORECLR // PAL doesn't support eventing, and we don't compile event providers for coreclr
if (_bUsingModernResourceManagement == false)
{
#if !MONO
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled()) {
CultureInfo culture = CultureInfo.InvariantCulture;
String defaultResName = GetResourceFileName(culture);
@@ -533,7 +534,7 @@ namespace System.Resources {
FrameworkEventSource.Log.ResourceManagerNeutralResourcesNotFound(BaseNameField, MainAssembly, outputResName);
}
}
#endif
#pragma warning disable 618
ResourceSets = new Hashtable(); // for backward compatibility
#pragma warning restore 618

View File

@@ -94,7 +94,7 @@ namespace System.Resources {
private const int AverageValueSize = 40;
private Dictionary<String, Object> _resourceList;
private Stream _output;
internal Stream _output;
private Dictionary<String, Object> _caseInsensitiveDups;
private Dictionary<String, PrecannedResource> _preserializedData;
private const int _DefaultBufferSize = 4096;