Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -7,13 +7,13 @@
//
// Class: __HResults
//
// <OWNER>[....]</OWNER>
// <OWNER>jathaine</OWNER>
//
// Purpose: Define HResult constants returned by the Windows Modern Resource Manager
// and consumed by System.Resources.ResourceManager.
//
//===========================================================================*/
#if !FEATURE_CORECLR
#if FEATURE_APPX
namespace System.Resources {
using System;
// Only static data no need to serialize
@@ -23,4 +23,4 @@ namespace System.Resources {
public const int ERROR_MRM_MAP_NOT_FOUND = unchecked((int)0x80073B1F);
}
}
#endif //FEATURE_CORECLR
#endif

View File

@@ -7,7 +7,7 @@
**
** Class: IResourceGroveler
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Interface for resource grovelers

View File

@@ -7,7 +7,7 @@
**
** Class: IResourceReader
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Abstraction to read streams of resources.

View File

@@ -7,7 +7,7 @@
**
** Class: IResourceWriter
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Default way to write strings to a COM+ resource

View File

@@ -7,7 +7,7 @@
**
** Class: LooselyLinkedResourceReference
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Provides a localizable way of retrieving a file
@@ -65,7 +65,7 @@ namespace System.Resources {
throw new ArgumentNullException("assembly");
Contract.EndContractBlock();
// @
// @TODO: Consider making this lookup case-insensitive for VB.
Stream data = assembly.GetManifestResourceStream(_manifestResourceName);
if (data == null)
throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_LooselyLinked", _manifestResourceName, assembly.FullName));

View File

@@ -91,9 +91,6 @@ namespace System.Resources {
if (satellite == null)
{
bool raiseException = (culture.HasInvariantCultureName && (_mediator.FallbackLoc == UltimateResourceFallbackLocation.Satellite));
#if FEATURE_SPLIT_RESOURCES
raiseException &= !_mediator.IsDebugSatellite;
#endif
// didn't find satellite, give error if necessary
if (raiseException)
{
@@ -158,9 +155,6 @@ namespace System.Resources {
{
// 4b. Didn't find stream; give error if necessary
bool raiseException = culture.HasInvariantCultureName;
#if FEATURE_SPLIT_RESOURCES
raiseException &= !_mediator.IsDebugSatellite;
#endif // FEATURE_SPLIT_RESOURCES
if (raiseException)
{
HandleResourceStreamMissing(fileName);
@@ -200,19 +194,6 @@ namespace System.Resources {
private CultureInfo UltimateFallbackFixup(CultureInfo lookForCulture)
{
#if FEATURE_SPLIT_RESOURCES
// special-case for mscorlib debug resources only
if (_mediator.IsDebugSatellite)
{
if (lookForCulture.HasInvariantCultureName &&
_mediator.FallbackLoc == UltimateResourceFallbackLocation.MainAssembly)
{
return _mediator.NeutralResourcesCulture;
}
return lookForCulture;
}
#endif
CultureInfo returnCulture = lookForCulture;
// If our neutral resources were written in this culture AND we know the main assembly
@@ -541,11 +522,11 @@ namespace System.Resources {
// if the stream is private and we're trying to access it from another
// assembly (ie, ResMgr in mscorlib accessing anything else), we
// require Reflection TypeInformation permission to be able to read
// this. <STRIP>This meaning of private in satellite assemblies is a really
// odd concept, and is orthogonal to the ResourceManager.
// We should not assume we can skip this security check,
// which means satellites must always use public manifest resources
// if you want to support semi-trusted code. </STRIP>
// this. <
#if !FEATURE_CORECLR && !MONO
if (s!=null) {
if (FrameworkEventSource.IsInitialized)
@@ -658,17 +639,7 @@ namespace System.Resources {
private String GetSatelliteAssemblyName()
{
String satAssemblyName = _mediator.MainAssembly.GetSimpleName();
#if FEATURE_SPLIT_RESOURCES
if (_mediator.IsDebugSatellite)
{
satAssemblyName = satAssemblyName + ".debug";
}
if (!satAssemblyName.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) {
#endif
satAssemblyName += ".resources";
#if FEATURE_SPLIT_RESOURCES
}
#endif
return satAssemblyName;
}

View File

@@ -41,7 +41,10 @@ namespace System.Resources {
//
// This is implemented in System.Runtime.WindowsRuntime as function System.Resources.WindowsRuntimeResourceManager,
// allowing us to ask for a WinRT-specific ResourceManager.
// Ideally this would be an interface, or at least an abstract class - but neither seems to play nice with FriendAccessAllowed.
// It is important to have WindowsRuntimeResourceManagerBase as regular class with virtual methods and default implementations.
// Defining WindowsRuntimeResourceManagerBase as abstract class or interface will cause issues when adding more methods to it
// because it<69>ll create dependency between mscorlib and System.Runtime.WindowsRuntime which will require always shipping both DLLs together.
// Also using interface or abstract class will not play nice with FriendAccessAllowed.
//
[FriendAccessAllowed]
[SecurityCritical]
@@ -57,6 +60,9 @@ namespace System.Resources {
[SecurityCritical]
get { return null; }
}
[SecurityCritical]
public virtual bool SetGlobalResourceContextDefaultCulture(CultureInfo ci) { return false; }
}
[FriendAccessAllowed]
@@ -200,9 +206,6 @@ namespace System.Resources {
[OptionalField(VersionAdded = 1)]
private bool UseSatelliteAssem; // Are all the .resources files in the
// main assembly, or in satellite assemblies for each culture?
#if FEATURE_SPLIT_RESOURCES
private bool _isDebugSatellite;
#endif // FEATURE_SPLIT_RESOURCES
#if RESOURCE_SATELLITE_CONFIG
private static volatile Hashtable _installedSatelliteInfo; // Give the user the option
// to prevent certain satellite assembly probes via a config file.
@@ -439,12 +442,6 @@ namespace System.Resources {
}
}
#if FEATURE_SPLIT_RESOURCES
internal ResourceManager(String baseName, Assembly assembly, bool isDebugSatellite) : this(baseName, assembly) {
_isDebugSatellite = isDebugSatellite;
}
#endif // FEATURE_SPLIT_RESOURCES
[OnDeserializing]
private void OnDeserializing(StreamingContext ctx)
{
@@ -736,7 +733,7 @@ namespace System.Resources {
// method, so the entire idea of a security check written this way is ----.
// So if we happen to return some resources in cases where we should really be
// doing a demand for member access permissions, we're not overly concerned.
// <STRIP>I verified this with our CAS expert. -- Brian, 2/11/2010</STRIP>
// <
return InternalGetResourceSet(culture, createIfNotExists, tryParents);
}
@@ -1036,6 +1033,57 @@ namespace System.Resources {
[NonSerialized]
private PRIExceptionInfo _PRIExceptionInfo; // Written only by SetAppXConfiguration
// When running under AppX, the following rules apply for resource lookup:
//
// Desktop
// -------
//
// 1) For Framework assemblies, we always use satellite assembly based lookup.
// 2) For non-FX assemblies, we use modern resource manager, with the premise being that app package
// contains the PRI resources since such assemblies are expected to be application assemblies.
//
// CoreCLR
// -------
//
// 1) For Framework assemblies, we always use satellite assembly based lookup.
// 2) For non-FX assemblies:
//
// a) If the assembly lives under PLATFORM_RESOURCE_ROOTS (as specified by the host during AppDomain creation),
// then we will use satellite assembly based lookup in assemblies like *.resources.dll.
//
// b) For any other non-FX assembly, we will use the modern resource manager with the premise that app package
// contains the PRI resources.
[SecuritySafeCritical]
private bool ShouldUseSatelliteAssemblyResourceLookupUnderAppX(RuntimeAssembly resourcesAssembly)
{
bool fUseSatelliteAssemblyResourceLookupUnderAppX = resourcesAssembly.IsFrameworkAssembly();
#if FEATURE_CORECLR
if (!fUseSatelliteAssemblyResourceLookupUnderAppX)
{
// Check to see if the assembly is under PLATFORM_RESOURCE_ROOTS. If it is, then we should use satellite assembly lookup for it.
String platformResourceRoots = (String)(AppDomain.CurrentDomain.GetData("PLATFORM_RESOURCE_ROOTS"));
if ((platformResourceRoots != null) && (platformResourceRoots != String.Empty))
{
string resourceAssemblyPath = resourcesAssembly.Location;
// Loop through the PLATFORM_RESOURCE_ROOTS and see if the assembly is contained in it.
foreach(string pathPlatformResourceRoot in platformResourceRoots.Split(Path.PathSeparator))
{
if (resourceAssemblyPath.StartsWith(pathPlatformResourceRoot, StringComparison.CurrentCultureIgnoreCase))
{
// Found the resource assembly to be present in one of the PLATFORM_RESOURCE_ROOT, so stop the enumeration loop.
fUseSatelliteAssemblyResourceLookupUnderAppX = true;
break;
}
}
}
}
#endif // FEATURE_CORECLR
return fUseSatelliteAssemblyResourceLookupUnderAppX;
}
[SecuritySafeCritical]
#endif // FEATURE_APPX
// Only call SetAppXConfiguration from ResourceManager constructors, and nowhere else.
@@ -1104,7 +1152,7 @@ namespace System.Resources {
{
// See AssemblyNative::IsFrameworkAssembly for details on which kinds of assemblies are considered Framework assemblies.
// The Modern Resource Manager is not used for such assemblies - they continue to use satellite assemblies (i.e. .resources.dll files).
_bUsingModernResourceManagement = !resourcesAssembly.IsFrameworkAssembly();
_bUsingModernResourceManagement = !ShouldUseSatelliteAssemblyResourceLookupUnderAppX(resourcesAssembly);
if (_bUsingModernResourceManagement)
{
@@ -1321,7 +1369,7 @@ namespace System.Resources {
throw new ArgumentNullException("name");
Contract.EndContractBlock();
#if !FEATURE_CORECLR
#if FEATURE_APPX
if(s_IsAppXModel)
{
// If the caller explictily passed in a culture that was obtained by calling CultureInfo.CurrentUICulture,
@@ -1631,13 +1679,6 @@ namespace System.Resources {
get { return _rm.m_callingAssembly; }
}
#if FEATURE_SPLIT_RESOURCES
internal bool IsDebugSatellite
{
get { return _rm._isDebugSatellite; }
}
#endif
internal RuntimeAssembly MainAssembly
{
get { return (RuntimeAssembly)_rm.MainAssembly; }

View File

@@ -1398,22 +1398,24 @@ namespace System.Resources {
String key;
Object value = null;
lock (_reader._resCache) {
key = _reader.AllocateStringForNameIndex(_currentName, out _dataPosition);
ResourceLocator locator;
if (_reader._resCache.TryGetValue(key, out locator)) {
value = locator.Value;
}
if (value == null) {
if (_dataPosition == -1)
value = _reader.GetValueForNameIndex(_currentName);
else
value = _reader.LoadObject(_dataPosition);
// If enumeration and subsequent lookups happen very
// frequently in the same process, add a ResourceLocator
// to _resCache here. But [....] enumerates and
// just about everyone else does lookups. So caching
// here may bloat working set.
lock (_reader) { // locks should be taken in the same order as in RuntimeResourceSet.GetObject to avoid deadlock
lock (_reader._resCache) {
key = _reader.AllocateStringForNameIndex(_currentName, out _dataPosition); // AllocateStringForNameIndex could lock on _reader
ResourceLocator locator;
if (_reader._resCache.TryGetValue(key, out locator)) {
value = locator.Value;
}
if (value == null) {
if (_dataPosition == -1)
value = _reader.GetValueForNameIndex(_currentName);
else
value = _reader.LoadObject(_dataPosition);
// If enumeration and subsequent lookups happen very
// frequently in the same process, add a ResourceLocator
// to _resCache here. But [....] enumerates and
// just about everyone else does lookups. So caching
// here may bloat working set.
}
}
}
return new DictionaryEntry(key, value);

View File

@@ -7,7 +7,7 @@
**
** Class: ResourceTypeCode
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Marker for types in .resources files

View File

@@ -7,9 +7,9 @@
**
** Enum: UltimateResourceFallbackLocation
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
** <EMAIL>Author: Brian Grunkemeyer ([....])</EMAIL>
** <EMAIL>Author: Brian Grunkemeyer (BrianGru)</EMAIL>
**
** Purpose: Tells the ResourceManager where to find the
** ultimate fallback resources for your assembly.