Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@ -39,5 +39,16 @@ namespace System
return LocalAppContext.GetCachedSwitchValue(@"Switch.System.Xml.IgnoreKindInUtcTimeSerialization", ref _ignoreKindInUtcTimeSerialization);
}
}
private static int _enableTimeSpanSerialization;
public static bool EnableTimeSpanSerialization
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return LocalAppContext.GetCachedSwitchValue(@"Switch.System.Xml.EnableTimeSpanSerialization", ref _enableTimeSpanSerialization);
}
}
}
}

View File

@ -14,6 +14,7 @@ namespace System.Xml.XmlConfiguration {
internal const string ProhibitDefaultResolverName = "prohibitDefaultResolver";
internal const string LimitXPathComplexityName = "limitXPathComplexity";
internal const string EnableMemberAccessForXslCompiledTransformName = "enableMemberAccessForXslCompiledTransform";
internal const string CollapseWhiteSpaceIntoEmptyStringName = "CollapseWhiteSpaceIntoEmptyString";
internal const string XmlConfigurationSectionName = "system.xml";
@ -62,6 +63,46 @@ namespace System.Xml.XmlConfiguration {
else
return new XmlUrlResolver();
}
#if CONFIGURATION_DEP
[ConfigurationProperty(XmlConfigurationString.CollapseWhiteSpaceIntoEmptyStringName, DefaultValue = "false")]
#endif
public string CollapseWhiteSpaceIntoEmptyStringString {
get {
#if CONFIGURATION_DEP
return (string)this[XmlConfigurationString.CollapseWhiteSpaceIntoEmptyStringName];
#else
return null;
#endif
}
set {
#if CONFIGURATION_DEP
this[XmlConfigurationString.CollapseWhiteSpaceIntoEmptyStringName] = value;
#endif
}
}
private bool _CollapseWhiteSpaceIntoEmptyString {
get {
string value = CollapseWhiteSpaceIntoEmptyStringString;
bool result;
XmlConvert.TryToBoolean(value, out result);
return result;
}
}
//check the config every time, otherwise will have problem in different asp.net pages which have different settings.
//ConfigurationManager will cache the section result, so expect no perf issue.
internal static bool CollapseWhiteSpaceIntoEmptyString {
get {
#if CONFIGURATION_DEP
XmlReaderSection section = System.Configuration.ConfigurationManager.GetSection(XmlConfigurationString.XmlReaderSectionPath) as XmlReaderSection;
return (section != null) ? section._CollapseWhiteSpaceIntoEmptyString : false;
#else
return false;
#endif
}
}
}
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]

View File

@ -1113,8 +1113,23 @@ namespace System.Xml.Serialization {
case TypeCode.Empty:
case TypeCode.DBNull:
default:
Debug.Assert(false, "UnknownConstantType");
throw new NotSupportedException("UnknownConstantType"); //.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnknownConstantType, DataContract.GetClrTypeFullName(valueType))));
if (valueType == typeof(TimeSpan) && LocalAppContextSwitches.EnableTimeSpanSerialization)
{
ConstructorInfo TimeSpan_ctor = typeof(TimeSpan).GetConstructor(
CodeGenerator.InstanceBindingFlags,
null,
new Type[] { typeof(Int64) },
null
);
Ldc(((TimeSpan)o).Ticks); // ticks
New(TimeSpan_ctor);
break;
}
else
{
Debug.Assert(false, "UnknownConstantType");
throw new NotSupportedException("UnknownConstantType"); //.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnknownConstantType, DataContract.GetClrTypeFullName(valueType))));
}
}
}
}

View File

@ -154,6 +154,18 @@ namespace System.Xml.Serialization {
WriteElementStringRaw(@"guid", @"", System.Xml.XmlConvert.ToString((System.Guid)((System.Guid)o)));
}
internal void Write_TimeSpan(object o)
{
WriteStartDocument();
if (o == null)
{
WriteEmptyTag(@"TimeSpan", @"");
return;
}
TimeSpan timeSpan = (TimeSpan)o;
WriteElementStringRaw(@"TimeSpan", @"", System.Xml.XmlConvert.ToString(timeSpan));
}
internal void Write_char(object o) {
WriteStartDocument();
if (o == null) {
@ -489,6 +501,38 @@ namespace System.Xml.Serialization {
return (object)o;
}
internal object Read_TimeSpan()
{
object o = null;
Reader.MoveToContent();
if (Reader.NodeType == System.Xml.XmlNodeType.Element)
{
if (((object)Reader.LocalName == (object)id19_TimeSpan && (object)Reader.NamespaceURI == (object)id2_Item))
{
if (Reader.IsEmptyElement)
{
Reader.Skip();
//For backward compatibiity
//When using old serializer, the serialized TimeSpan value is empty string
o = default(TimeSpan);
}
else
{
o = System.Xml.XmlConvert.ToTimeSpan(Reader.ReadElementString());
}
}
else
{
throw CreateUnknownNodeException();
}
}
else
{
UnknownNode(null);
}
return (object)o;
}
internal object Read_char() {
object o = null;
Reader.MoveToContent();
@ -542,6 +586,7 @@ namespace System.Xml.Serialization {
System.String id9_decimal;
System.String id8_double;
System.String id17_guid;
System.String id19_TimeSpan;
System.String id2_Item;
System.String id13_unsignedShort;
System.String id18_char;
@ -563,6 +608,10 @@ namespace System.Xml.Serialization {
id9_decimal = Reader.NameTable.Add(@"decimal");
id8_double = Reader.NameTable.Add(@"double");
id17_guid = Reader.NameTable.Add(@"guid");
if (LocalAppContextSwitches.EnableTimeSpanSerialization)
{
id19_TimeSpan = Reader.NameTable.Add(@"TimeSpan");
}
id2_Item = Reader.NameTable.Add(@"");
id13_unsignedShort = Reader.NameTable.Add(@"unsignedShort");
id18_char = Reader.NameTable.Add(@"char");

View File

@ -485,6 +485,10 @@ namespace System.Xml.Serialization {
AddNonXsdPrimitive(typeof(Guid), "guid", UrtTypes.Namespace, "Guid", new XmlQualifiedName("string", XmlSchema.Namespace), new XmlSchemaFacet[] { guidPattern }, TypeFlags.CanBeAttributeValue | TypeFlags.CanBeElementValue | TypeFlags.XmlEncodingNotRequired | TypeFlags.IgnoreDefault);
AddNonXsdPrimitive(typeof(char), "char", UrtTypes.Namespace, "Char", new XmlQualifiedName("unsignedShort", XmlSchema.Namespace), new XmlSchemaFacet[0], TypeFlags.CanBeAttributeValue | TypeFlags.CanBeElementValue | TypeFlags.HasCustomFormatter | TypeFlags.IgnoreDefault);
if (LocalAppContextSwitches.EnableTimeSpanSerialization)
{
AddNonXsdPrimitive(typeof(TimeSpan), "TimeSpan", UrtTypes.Namespace, "TimeSpan", new XmlQualifiedName("duration", XmlSchema.Namespace), new XmlSchemaFacet[0], TypeFlags.CanBeAttributeValue | TypeFlags.CanBeElementValue | TypeFlags.XmlEncodingNotRequired);
}
AddSoapEncodedTypes(Soap.Encoding);
@ -525,6 +529,8 @@ namespace System.Xml.Serialization {
return true;
else if (type == typeof(Guid))
return true;
else if (LocalAppContextSwitches.EnableTimeSpanSerialization && type == typeof(TimeSpan))
return true;
else if (type == typeof(XmlNode[])) {
return true;
}

View File

@ -1 +1 @@
5a3d21642d46f4e2e06e88f9fc591742bf823d14
64be0a91128eb66e3c122685d18b2139659a9f02

View File

@ -1 +1 @@
6ba4b2d7fb5998e5aa8751d6aee797b977883f02
918b405d554f8ab363b414a3ba4f1ffa72b5cc88

View File

@ -1 +1 @@
d15b2bf9bf55da3fee70ba528b0a9592c1d3f194
fbb688875939e12e36445f8bc682eef0150e41fb

View File

@ -793,6 +793,9 @@ namespace System.Xml.Serialization {
else if (primitiveType == typeof(Guid)) {
writer.Write_guid(o);
}
else if (primitiveType == typeof(TimeSpan)) {
writer.Write_TimeSpan(o);
}
else {
throw new InvalidOperationException(Res.GetString(Res.XmlUnxpectedType, primitiveType.FullName));
}
@ -853,17 +856,20 @@ namespace System.Xml.Serialization {
default:
if (primitiveType == typeof(XmlQualifiedName)) {
o = reader.Read_QName();
}
o = reader.Read_QName();
}
else if (primitiveType == typeof(byte[])) {
o = reader.Read_base64Binary();
}
o = reader.Read_base64Binary();
}
else if (primitiveType == typeof(Guid)) {
o = reader.Read_guid();
}
o = reader.Read_guid();
}
else if (primitiveType == typeof(TimeSpan) && LocalAppContextSwitches.EnableTimeSpanSerialization) {
o = reader.Read_TimeSpan();
}
else {
throw new InvalidOperationException(Res.GetString(Res.XmlUnxpectedType, primitiveType.FullName));
}
throw new InvalidOperationException(Res.GetString(Res.XmlUnxpectedType, primitiveType.FullName));
}
break;
}
return o;

View File

@ -28,7 +28,7 @@ namespace System.Xml {
while ( xmlCharType.IsWhiteSpace( value[startPos] ) ) {
startPos++;
if ( startPos == len ) {
return " ";
return (System.Xml.XmlConfiguration.XmlReaderSection.CollapseWhiteSpaceIntoEmptyString)?"":" ";
}
}