Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Config_unable_to_get_section" xml:space="preserve">
<value>Unable to retrieve configuration section '{0}'.</value>
</data>
<data name="TimeSpan_invalid_format" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a time interval that can be parsed by System.TimeSpan.Parse.</value>
</data>
<data name="Value_must_be_non_negative_integer" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a non-negative 32-bit integer.</value>
</data>
<data name="Value_must_be_positive_integer" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a positive 32-bit integer.</value>
</data>
<data name="Value_too_big" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value cannot be greater than '{2}'.</value>
</data>
<data name="Empty_collection" xml:space="preserve">
<value>The collection '{0}' is empty.</value>
</data>
<data name="Collection_contains_null_element" xml:space="preserve">
<value>The collection '{0}' contains a null element.</value>
</data>
<data name="Collection_contains_null_or_empty_string" xml:space="preserve">
<value>The collection '{0}' contains a null or empty string.</value>
</data>
<data name="Method_already_invoked" xml:space="preserve">
<value>The method has already been invoked, and can only be invoked once.</value>
</data>
<data name="Property_already_set" xml:space="preserve">
<value>The property has already been set, and can only be set once.</value>
</data>
<data name="Invalid_state" xml:space="preserve">
<value>Invalid state.</value>
</data>
<data name="Init_not_complete" xml:space="preserve">
<value>Initialization has not completed yet. The InitializationComplete method must be invoked before Dispose is invoked.</value>
</data>
<data name="Default_is_reserved" xml:space="preserve">
<value>Default is a reserved MemoryCache name.</value>
</data>
<data name="Invalid_expiration_combination" xml:space="preserve">
<value>AbsoluteExpiration must be DateTimeOffset.MaxValue or SlidingExpiration must be TimeSpan.Zero.</value>
</data>
<data name="Invalid_callback_combination" xml:space="preserve">
<value>Only one callback can be specified. Either RemovedCallback or UpdateCallback must be null.</value>
</data>
<data name="Invalid_argument_combination" xml:space="preserve">
<value>One of the following parameters must be specified: dependencies, absoluteExpiration, slidingExpiration.</value>
</data>
<data name="Update_callback_must_be_null" xml:space="preserve">
<value>CacheItemUpdateCallback must be null.</value>
</data>
<data name="Argument_out_of_range" xml:space="preserve">
<value>'{0}' must be greater than or equal to '{1}' and less than or equal to '{2}'.</value>
</data>
<data name="Empty_string_invalid" xml:space="preserve">
<value>An empty string is invalid.</value>
</data>
<data name="RegionName_not_supported" xml:space="preserve">
<value>The parameter regionName must be null.</value>
</data>
<data name="Value_must_be_boolean" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a boolean.</value>
</data>
</root>

View File

@ -222,6 +222,15 @@ namespace System.Runtime.Caching.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Invalid configuration: {0}=&quot;{1}&quot;. The {0} value must be a boolean..
/// </summary>
internal static string Value_must_be_boolean {
get {
return ResourceManager.GetString("Value_must_be_boolean", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to An empty string is invalid..
/// </summary>

View File

@ -44,7 +44,8 @@ namespace System.Runtime.Caching {
_gen2Count = GC.CollectionCount(2);
_cacheSizeSamples = new long[SAMPLE_COUNT];
_cacheSizeSampleTimes = new DateTime[SAMPLE_COUNT];
InitMemoryCacheManager();
if (memoryCache.UseMemoryCacheManager)
InitMemoryCacheManager(); // This magic thing connects us to ObjectCacheHost magically. :/
InitDisposableMembers(cacheMemoryLimitMegabytes);
}

View File

@ -12,6 +12,7 @@ namespace System.Runtime.Caching.Configuration {
internal const string CacheMemoryLimitMegabytes = "cacheMemoryLimitMegabytes";
internal const string PhysicalMemoryLimitPercentage = "physicalMemoryLimitPercentage";
internal const string PollingInterval = "pollingInterval";
internal const string UseMemoryCacheManager = "useMemoryCacheManager";
internal const int DefaultPollingTimeMilliseconds = 120000;
internal static int GetIntValue(NameValueCollection config, string valueName, int defaultValue, bool zeroAllowed, int maxValueAllowed) {
@ -63,5 +64,19 @@ namespace System.Runtime.Caching.Configuration {
return iValue;
}
internal static bool GetBooleanValue(NameValueCollection config, string valueName, bool defaultValue) {
string sValue = config[valueName];
if (sValue == null) {
return defaultValue;
}
bool bValue;
if (!Boolean.TryParse(sValue, out bValue)) {
throw new ArgumentException(RH.Format(R.Value_must_be_boolean, valueName, sValue), "config");
}
return bValue;
}
}
}

View File

@ -34,6 +34,7 @@ namespace System.Runtime.Caching {
private string _name;
private PerfCounters _perfCounters;
private bool _configLess;
private bool _useMemoryCacheManager = true;
EventHandler _onAppDomainUnload;
UnhandledExceptionEventHandler _onUnhandledException;
@ -258,6 +259,10 @@ namespace System.Runtime.Caching {
get { return _name; }
}
internal bool UseMemoryCacheManager {
get { return _useMemoryCacheManager; }
}
// Percentage of physical memory that can be used before
// the cache begins to forcibly remove items.
public long PhysicalMemoryLimit {
@ -280,7 +285,7 @@ namespace System.Runtime.Caching {
Init(null);
}
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Justification="This is assembly is a special case approved by the NetFx API review board")]
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Justification = "This is assembly is a special case approved by the NetFx API review board")]
public MemoryCache(string name, NameValueCollection config = null) {
if (name == null) {
throw new ArgumentNullException("name");
@ -294,12 +299,12 @@ namespace System.Runtime.Caching {
_name = name;
Init(config);
}
// Configless is used when redirecting ASP.NET cache into the MemoryCache. This avoids infinite recursion
// ignoreConfigSection is used when redirecting ASP.NET cache into the MemoryCache. This avoids infinite recursion
// due to the fact that the (ASP.NET) config system uses the cache, and the cache uses the
// config system. This method could be made public, perhaps with CAS to prevent partial trust callers.
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Grandfathered suppression from original caching code checkin")]
internal MemoryCache(string name, NameValueCollection config, bool configLess) {
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Justification = "This is assembly is a special case approved by the NetFx API review board")]
public MemoryCache(string name, NameValueCollection config, bool ignoreConfigSection) {
if (name == null) {
throw new ArgumentNullException("name");
}
@ -310,14 +315,15 @@ namespace System.Runtime.Caching {
throw new ArgumentException(R.Default_is_reserved, "name");
}
_name = name;
_configLess = configLess;
_configLess = ignoreConfigSection;
Init(config);
}
private void Init(NameValueCollection config) {
_storeCount = Environment.ProcessorCount;
#if MONO
if (config != null) {
#if MONO
if (config ["__MonoEmulateOneCPU"] == "true")
_storeCount = 1;
if (config ["__MonoTimerPeriod"] != null) {
@ -328,9 +334,11 @@ namespace System.Runtime.Caching {
//
}
}
#endif
_useMemoryCacheManager = ConfigUtil.GetBooleanValue(config, ConfigUtil.UseMemoryCacheManager, true);
}
#endif
_storeRefs = new GCHandleRef<MemoryCacheStore>[_storeCount];
InitDisposableMembers(config);
}
@ -668,6 +676,11 @@ namespace System.Runtime.Caching {
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Justification="This is assembly is a special case approved by the NetFx API review board")]
public override object Remove(string key, string regionName = null) {
return Remove(key, CacheEntryRemovedReason.Removed, regionName);
}
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Justification = "This is assembly is a special case approved by the NetFx API review board")]
public object Remove(string key, CacheEntryRemovedReason reason, string regionName = null) {
if (regionName != null) {
throw new NotSupportedException(R.RegionName_not_supported);
}
@ -677,7 +690,7 @@ namespace System.Runtime.Caching {
if (IsDisposed) {
return null;
}
MemoryCacheEntry entry = RemoveEntry(key, null, CacheEntryRemovedReason.Removed);
MemoryCacheEntry entry = RemoveEntry(key, null, reason);
return (entry != null) ? entry.Value : null;
}
@ -695,6 +708,14 @@ namespace System.Runtime.Caching {
return count;
}
public long GetLastSize(string regionName = null) {
if (regionName != null) {
throw new NotSupportedException(R.RegionName_not_supported);
}
return _stats.GetLastSize();
}
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Justification="This is assembly is a special case approved by the NetFx API review board")]
public override IDictionary<string, object> GetValues(IEnumerable<String> keys, string regionName = null) {
if (regionName != null) {

View File

@ -85,6 +85,10 @@ namespace System.Runtime.Caching {
CacheManagerThread(0);
}
internal long GetLastSize() {
return this._cacheMemoryMonitor.PressureLast;
}
private int GetPercentToTrim() {
int gen2Count = GC.CollectionCount(2);
// has there been a Gen 2 Collection since the last trim?