Imported Upstream version 5.10.0.69

Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-29 19:03:06 +00:00
parent d8f8abd549
commit e2950ec768
6283 changed files with 453847 additions and 91879 deletions

View File

@@ -1,5 +1,64 @@
<?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">
@@ -373,9 +432,6 @@
<data name="ObjectTableOverflow" xml:space="preserve">
<value>An internal error has occurred. Object table overflow. This could be caused by serializing or deserializing extremely large object graphs.</value>
</data>
<data name="OrderCannotBeNegative" xml:space="preserve">
<value>Property 'Order' in DataMemberAttribute attribute cannot be a negative number.</value>
</data>
<data name="ParameterCountMismatch" xml:space="preserve">
<value>Invalid number of parameters to call method '{0}'. Expected '{1}' parameters, but '{2}' were provided.</value>
</data>
@@ -733,9 +789,6 @@
<data name="XmlMaxBytesPerReadExceeded" xml:space="preserve">
<value>The 'maximum bytes per Read operation' quota ({0}) has been exceeded while reading XML data. Long element start tags (consisting of the element name, attribute names and attribute values) may trigger this quota. This quota may be increased by changing the MaxBytesPerRead property on the XmlDictionaryReaderQuotas object used when creating the XML reader.</value>
</data>
<data name="XmlMaxNameTableCharCountExceeded" xml:space="preserve">
<value>The maximum nametable character count quota ({0}) has been exceeded while reading XML data. The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota. This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader.</value>
</data>
<data name="XmlMaxDepthExceeded" xml:space="preserve">
<value>The maximum read depth ({0}) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota. This quota may be increased by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader.</value>
</data>
@@ -850,25 +903,25 @@
<data name="GenericCallbackException" xml:space="preserve">
<value>A user callback threw an exception. Check the exception stack and inner exception to determine the callback that failed.</value>
</data>
<data name="JsonEncounteredUnexpectedCharacter" xml:space="preserve">
<data name="JsonEncounteredUnexpectedCharacter" xml:space="preserve">
<value>Encountered unexpected character '{0}'.</value>
</data>
<data name="JsonOffsetExceedsBufferSize" xml:space="preserve">
<data name="JsonOffsetExceedsBufferSize" xml:space="preserve">
<value>The specified offset exceeds the buffer size ({0} bytes).</value>
</data>
<data name="JsonSizeExceedsRemainingBufferSpace" xml:space="preserve">
<data name="JsonSizeExceedsRemainingBufferSpace" xml:space="preserve">
<value>The specified size exceeds the remaining buffer space ('{0}' bytes).</value>
</data>
<data name="InvalidCharacterEncountered" xml:space="preserve">
<data name="InvalidCharacterEncountered" xml:space="preserve">
<value>Encountered invalid character '{0}'.</value>
</data>
<data name="JsonInvalidFFFE" xml:space="preserve">
<data name="JsonInvalidFFFE" xml:space="preserve">
<value>Characters with hexadecimal values 0xFFFE and 0xFFFF are not valid.</value>
</data>
<data name="JsonDateTimeOutOfRange" xml:space="preserve">
<data name="JsonDateTimeOutOfRange" xml:space="preserve">
<value>DateTime values that are greater than DateTime.MaxValue or smaller than DateTime.MinValue when converted to UTC cannot be serialized to JSON.</value>
</data>
<data name="JsonWriteArrayNotSupported" xml:space="preserve">
<data name="JsonWriteArrayNotSupported" xml:space="preserve">
<value>To write JSON arrays, use XML writer methods to write the attribute type='array' followed by methods like WriteStartElement (with the local name 'item'), WriteAttributeString, and WriteEndElement to write the JSON array items.</value>
</data>
<data name="JsonMethodNotSupported" xml:space="preserve">
@@ -889,7 +942,7 @@
<data name="JsonMustSpecifyDataType" xml:space="preserve">
<value>You must write an attribute '{0}'='{1}' after writing the attribute with local name '{2}'.</value>
</data>
<data name="JsonXmlProcessingInstructionNotSupported" xml:space="preserve">
<data name="JsonXmlProcessingInstructionNotSupported" xml:space="preserve">
<value>Processing instructions (other than the XML declaration) are not supported.</value>
</data>
<data name="JsonXmlInvalidDeclaration" xml:space="preserve">
@@ -993,7 +1046,7 @@
</data>
<data name="FactoryObjectContainsSelfReference" xml:space="preserve">
<value>Object graph of type '{0}' with Id '{2}' contains a reference to itself. The object has been replaced with a new object of type '{1}' either because it implements IObjectReference or because it is surrogated. The serializer does not support fixing up the nested reference to the new object and cannot deserialize this object. Consider changing the object to remove the nested self-reference.</value>
</data>
</data>
<data name="RecursiveCollectionType" xml:space="preserve">
<value>Type '{0}' is a recursive collection data contract which is not supported. Consider modifying the definition of collection '{0}' to remove references to itself.</value>
</data>
@@ -1006,30 +1059,6 @@
<data name="DupTypeContractInDataContractSet" xml:space="preserve">
<value>DataContract for type '{0}' cannot be added to DataContractSet since type '{1}' with the same data contract name '{2}' in namespace '{3}' is already present and the contracts are not equivalent.</value>
</data>
<data name="ReferencedTypesCannotContainNull" xml:space="preserve">
<value>ReferencedTypes specified via ImportOptions must contain valid types. Cannot contain null.</value>
</data>
<data name="ReferencedCollectionTypesCannotContainNull" xml:space="preserve">
<value>ReferencedCollectionTypes specified via ImportOptions must contain valid types. Cannot contain null.</value>
</data>
<data name="ReferencedTypeMatchingMessage" xml:space="preserve">
<value>(matching)</value>
</data>
<data name="ReferencedTypeNotMatchingMessage" xml:space="preserve">
<value>(not matching)</value>
</data>
<data name="AmbiguousReferencedTypes1" xml:space="preserve">
<value>List of referenced types contains more than one type with same data contract name. Need to exclude all but one of the following types. Only matching types can be valid references: {0}</value>
</data>
<data name="AmbiguousReferencedTypes3" xml:space="preserve">
<value>List of referenced types contains more than one type with data contract name '{0}' in namespace '{1}'. Need to exclude all but one of the following types. Only matching types can be valid references: {2}</value>
</data>
<data name="AmbiguousReferencedCollectionTypes1" xml:space="preserve">
<value>List of referenced collection types contains more than one type with same data contract name. Include only one of the following types. Only matching types can be valid references: {0}</value>
</data>
<data name="AmbiguousReferencedCollectionTypes3" xml:space="preserve">
<value>List of referenced collection types contains more than one type with data contract name '{0}' in namespace '{1}'. Include only one of the following types. Only matching types can be valid references: {2}</value>
</data>
<data name="GenericTypeNotExportable" xml:space="preserve">
<value>Type '{0}' cannot be exported as a schema type because it is an open generic type. You can only export a generic type if all its generic parameter types are actual types.</value>
</data>
@@ -1098,7 +1127,7 @@
</data>
<data name="PlatformNotSupported_NetDataContractSerializer" xml:space="preserve">
<value>System.Runtime.Serialization.NetDataContractSerializer is not supported on this platform.</value>
</data>
</data>
<data name="PlatformNotSupported_IDataContractSurrogate" xml:space="preserve">
<value>The implementation of the function requires System.Runtime.Serialization.IDataContractSurrogate which is not supported on this platform.</value>
</data>
@@ -1126,4 +1155,4 @@
<data name="FailedToCreateMethodDelegate" xml:space="preserve">
<value>Failed to create Delegate for method '{0}' of type '{1}'.</value>
</data>
</root>
</root>

View File

@@ -15,7 +15,6 @@
<!-- We do not want to block reflection for this assembly -->
<BlockReflectionAttribute Condition="'$(TargetGroup)'=='uapaot'">false</BlockReflectionAttribute>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />

View File

@@ -14,11 +14,8 @@ namespace System.Runtime.Serialization
{
private Dictionary<XmlQualifiedName, DataContract> _contracts;
private Dictionary<DataContract, object> _processedContracts;
private DataContractDictionary _knownTypesForObject;
private ICollection<Type> _referencedTypes;
private ICollection<Type> _referencedCollectionTypes;
private Dictionary<XmlQualifiedName, object> _referencedTypesDictionary;
private Dictionary<XmlQualifiedName, object> _referencedCollectionTypesDictionary;
#if SUPPORT_SURROGATE
private IDataContractSurrogate _dataContractSurrogate;
@@ -91,11 +88,6 @@ namespace System.Runtime.Serialization
}
}
#endif
internal DataContractDictionary KnownTypesForObject
{
get { return _knownTypesForObject; }
set { _knownTypesForObject = value; }
}
internal void Add(Type type)
{
@@ -310,35 +302,13 @@ namespace System.Runtime.Serialization
{
SurrogateDataTable[key] = surrogateData;
}
#endif
public DataContract this[XmlQualifiedName key]
{
get
{
DataContract dataContract = DataContract.GetBuiltInDataContract(key.Name, key.Namespace);
if (dataContract == null)
{
Contracts.TryGetValue(key, out dataContract);
}
return dataContract;
}
}
#if SUPPORT_SURROGATE
public IDataContractSurrogate DataContractSurrogate
{
get { return _dataContractSurrogate; }
}
#endif
public bool Remove(XmlQualifiedName key)
{
if (DataContract.GetBuiltInDataContract(key.Name, key.Namespace) != null)
return false;
return Contracts.Remove(key);
}
public IEnumerator<KeyValuePair<XmlQualifiedName, DataContract>> GetEnumerator()
{
return Contracts.GetEnumerator();
@@ -368,178 +338,5 @@ namespace System.Runtime.Serialization
ProcessedContracts.Add(dataContract, info);
}
#endif
private Dictionary<XmlQualifiedName, object> GetReferencedTypes()
{
if (_referencedTypesDictionary == null)
{
_referencedTypesDictionary = new Dictionary<XmlQualifiedName, object>();
//Always include Nullable as referenced type
//Do not allow surrogating Nullable<T>
_referencedTypesDictionary.Add(DataContract.GetStableName(Globals.TypeOfNullable), Globals.TypeOfNullable);
if (_referencedTypes != null)
{
foreach (Type type in _referencedTypes)
{
if (type == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ReferencedTypesCannotContainNull)));
AddReferencedType(_referencedTypesDictionary, type);
}
}
}
return _referencedTypesDictionary;
}
private Dictionary<XmlQualifiedName, object> GetReferencedCollectionTypes()
{
if (_referencedCollectionTypesDictionary == null)
{
_referencedCollectionTypesDictionary = new Dictionary<XmlQualifiedName, object>();
if (_referencedCollectionTypes != null)
{
foreach (Type type in _referencedCollectionTypes)
{
if (type == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ReferencedCollectionTypesCannotContainNull)));
AddReferencedType(_referencedCollectionTypesDictionary, type);
}
}
XmlQualifiedName genericDictionaryName = DataContract.GetStableName(Globals.TypeOfDictionaryGeneric);
if (!_referencedCollectionTypesDictionary.ContainsKey(genericDictionaryName) && GetReferencedTypes().ContainsKey(genericDictionaryName))
AddReferencedType(_referencedCollectionTypesDictionary, Globals.TypeOfDictionaryGeneric);
}
return _referencedCollectionTypesDictionary;
}
private void AddReferencedType(Dictionary<XmlQualifiedName, object> referencedTypes, Type type)
{
if (IsTypeReferenceable(type))
{
XmlQualifiedName stableName;
try
{
stableName = this.GetStableName(type);
}
catch (InvalidDataContractException)
{
// Type not referenceable if we can't get a stable name.
return;
}
catch (InvalidOperationException)
{
// Type not referenceable if we can't get a stable name.
return;
}
object value;
if (referencedTypes.TryGetValue(stableName, out value))
{
Type referencedType = value as Type;
if (referencedType != null)
{
if (referencedType != type)
{
referencedTypes.Remove(stableName);
List<Type> types = new List<Type>();
types.Add(referencedType);
types.Add(type);
referencedTypes.Add(stableName, types);
}
}
else
{
List<Type> types = (List<Type>)value;
if (!types.Contains(type))
types.Add(type);
}
}
else
referencedTypes.Add(stableName, type);
}
}
internal bool TryGetReferencedType(XmlQualifiedName stableName, DataContract dataContract, out Type type)
{
return TryGetReferencedType(stableName, dataContract, false/*useReferencedCollectionTypes*/, out type);
}
internal bool TryGetReferencedCollectionType(XmlQualifiedName stableName, DataContract dataContract, out Type type)
{
return TryGetReferencedType(stableName, dataContract, true/*useReferencedCollectionTypes*/, out type);
}
private bool TryGetReferencedType(XmlQualifiedName stableName, DataContract dataContract, bool useReferencedCollectionTypes, out Type type)
{
object value;
Dictionary<XmlQualifiedName, object> referencedTypes = useReferencedCollectionTypes ? GetReferencedCollectionTypes() : GetReferencedTypes();
if (referencedTypes.TryGetValue(stableName, out value))
{
type = value as Type;
if (type != null)
return true;
else
{
// Throw ambiguous type match exception
List<Type> types = (List<Type>)value;
StringBuilder errorMessage = new StringBuilder();
bool containsGenericType = false;
for (int i = 0; i < types.Count; i++)
{
Type conflictingType = types[i];
if (!containsGenericType)
containsGenericType = conflictingType.IsGenericTypeDefinition;
errorMessage.AppendFormat("{0}\"{1}\" ", Environment.NewLine, conflictingType.AssemblyQualifiedName);
if (dataContract != null)
{
DataContract other = this.GetDataContract(conflictingType);
errorMessage.Append(SR.Format(((other != null && other.Equals(dataContract)) ? SR.ReferencedTypeMatchingMessage : SR.ReferencedTypeNotMatchingMessage)));
}
}
if (containsGenericType)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(
(useReferencedCollectionTypes ? SR.AmbiguousReferencedCollectionTypes1 : SR.AmbiguousReferencedTypes1),
errorMessage.ToString())));
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(
(useReferencedCollectionTypes ? SR.AmbiguousReferencedCollectionTypes3 : SR.AmbiguousReferencedTypes3),
XmlConvert.DecodeName(stableName.Name),
stableName.Namespace,
errorMessage.ToString())));
}
}
}
type = null;
return false;
}
private static bool IsTypeReferenceable(Type type)
{
Type itemType;
try
{
return (type.IsSerializable ||
type.IsDefined(Globals.TypeOfDataContractAttribute, false) ||
(Globals.TypeOfIXmlSerializable.IsAssignableFrom(type) && !type.IsGenericTypeDefinition) ||
CollectionDataContract.IsCollection(type, out itemType) ||
ClassDataContract.IsNonAttributedTypeValidForSerialization(type));
}
catch (Exception ex)
{
// An exception can be thrown in the designer when a project has a runtime binding redirection for a referenced assembly or a reference dependent assembly.
// Type.IsDefined is known to throw System.IO.FileLoadException.
// ClassDataContract.IsNonAttributedTypeValidForSerialization is known to throw System.IO.FileNotFoundException.
// We guard against all non-critical exceptions.
if (DiagnosticUtility.IsFatal(ex))
{
throw;
}
}
return false;
}
}
}

View File

@@ -31,11 +31,6 @@ namespace System.Runtime.Serialization
_helper = new CriticalHelper(memberInfo);
}
internal DataMember(DataContract memberTypeContract, string name, bool isNullable, bool isRequired, bool emitDefaultValue, int order)
{
_helper = new CriticalHelper(memberTypeContract, name, isNullable, isRequired, emitDefaultValue, order);
}
internal MemberInfo MemberInfo
{
get
@@ -64,7 +59,7 @@ namespace System.Runtime.Serialization
{
get
{ return _helper.IsRequired; }
set
{ _helper.IsRequired = value; }
}
@@ -73,7 +68,7 @@ namespace System.Runtime.Serialization
{
get
{ return _helper.EmitDefaultValue; }
set
{ _helper.EmitDefaultValue = value; }
}
@@ -186,16 +181,6 @@ namespace System.Runtime.Serialization
_memberInfo = memberInfo;
}
internal CriticalHelper(DataContract memberTypeContract, string name, bool isNullable, bool isRequired, bool emitDefaultValue, int order)
{
this.MemberTypeContract = memberTypeContract;
this.Name = name;
this.IsNullable = isNullable;
this.IsRequired = isRequired;
this.EmitDefaultValue = emitDefaultValue;
this.Order = order;
}
internal MemberInfo MemberInfo
{
get { return _memberInfo; }

View File

@@ -73,11 +73,6 @@ namespace System.Runtime.Serialization
return new ArgumentException(message);
}
public static Exception ThrowHelperArgument(string paramName, string message)
{
return new ArgumentException(message, paramName);
}
internal static Exception ThrowHelperFatal(string message, Exception innerException)
{
return ThrowHelperError(new Exception(message, innerException));

View File

@@ -41,7 +41,6 @@ namespace System.Runtime.Serialization
private XmlNodeReader _xmlNodeReader;
#pragma warning restore 0649
private Queue<IDataNode> _deserializedDataNodes;
private XmlObjectSerializerReadContext _context;
private static Dictionary<string, string> s_nsToPrefixTable;
@@ -63,16 +62,6 @@ namespace System.Runtime.Serialization
_context = context;
}
internal void SetDeserializedValue(object obj)
{
IDataNode deserializedDataNode = (_deserializedDataNodes == null || _deserializedDataNodes.Count == 0) ? null : _deserializedDataNodes.Dequeue();
if (deserializedDataNode != null && !(obj is IDataNode))
{
deserializedDataNode.Value = obj;
deserializedDataNode.IsFinalValue = true;
}
}
internal IDataNode GetCurrentNode()
{
IDataNode retVal = _element.dataNode;
@@ -80,14 +69,6 @@ namespace System.Runtime.Serialization
return retVal;
}
internal void SetDataNode(IDataNode dataNode, string name, string ns)
{
SetNextElement(dataNode, name, ns, null);
_element = _nextElement;
_nextElement = null;
SetElement();
}
internal void Reset()
{
_localName = null;
@@ -100,7 +81,6 @@ namespace System.Runtime.Serialization
_element = null;
_nextElement = null;
_elements = null;
_deserializedDataNodes = null;
}
private bool IsXmlDataNode { get { return (_internalNodeType == ExtensionDataNodeType.Xml); } }
@@ -451,11 +431,6 @@ namespace System.Runtime.Serialization
throw NotImplemented.ByDesign;
}
private void SetNextElement(IDataNode node, string name, string ns, string prefix)
{
throw NotImplemented.ByDesign;
}
private void PushElement()
{
GrowElementsIfNeeded();
@@ -581,4 +556,4 @@ namespace System.Runtime.Serialization
}
}
}
}
}

View File

@@ -759,17 +759,6 @@ namespace System.Runtime.Serialization
}
}
private static Type s_typeOfListGeneric;
internal static Type TypeOfListGeneric
{
get
{
if (s_typeOfListGeneric == null)
s_typeOfListGeneric = typeof(List<>);
return s_typeOfListGeneric;
}
}
private static Type s_typeOfXmlElement;
internal static Type TypeOfXmlElement
{
@@ -855,8 +844,6 @@ namespace System.Runtime.Serialization
#endregion
private static Type s_typeOfScriptObject;
private static Func<object, string> s_serializeFunc;
private static Func<string, object> s_deserializeFunc;
internal static ClassDataContract CreateScriptObjectClassDataContract()
{
@@ -869,25 +856,6 @@ namespace System.Runtime.Serialization
return s_typeOfScriptObject != null && s_typeOfScriptObject.IsAssignableFrom(type);
}
internal static void SetScriptObjectJsonSerializer(Type typeOfScriptObject, Func<object, string> serializeFunc, Func<string, object> deserializeFunc)
{
Globals.s_typeOfScriptObject = typeOfScriptObject;
Globals.s_serializeFunc = serializeFunc;
Globals.s_deserializeFunc = deserializeFunc;
}
internal static string ScriptObjectJsonSerialize(object obj)
{
Debug.Assert(s_serializeFunc != null);
return Globals.s_serializeFunc(obj);
}
internal static object ScriptObjectJsonDeserialize(string json)
{
Debug.Assert(s_deserializeFunc != null);
return Globals.s_deserializeFunc(json);
}
public const bool DefaultIsRequired = false;
public const bool DefaultEmitDefaultValue = true;
public const int DefaultOrder = 0;

View File

@@ -4,22 +4,30 @@
using System;
namespace System.Runtime.Serialization
{
public class InvalidDataContractException : Exception
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public partial class InvalidDataContractException : Exception
{
public InvalidDataContractException() : base()
public InvalidDataContractException()
: base()
{
}
public InvalidDataContractException(String message) : base(message)
public InvalidDataContractException(String message)
: base(message)
{
}
public InvalidDataContractException(String message, Exception innerException) : base(message, innerException)
public InvalidDataContractException(String message, Exception innerException)
: base(message, innerException)
{
}
protected InvalidDataContractException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@@ -106,8 +106,8 @@ namespace System.Runtime.Serialization.Json
if (this.knownDataContracts == null && this.knownTypeList != null)
{
// This assignment may be performed concurrently and thus is a race condition.
// It's safe, however, because at worse a new (and identical) dictionary of
// data contracts will be created and re-assigned to this field. Introduction
// It's safe, however, because at worse a new (and identical) dictionary of
// data contracts will be created and re-assigned to this field. Introduction
// of a lock here could lead to deadlocks.
this.knownDataContracts = XmlObjectSerializerContext.GetDataContractsForKnownTypes(this.knownTypeList);
}
@@ -119,13 +119,6 @@ namespace System.Runtime.Serialization.Json
{
get { return _maxItemsInObjectGraph; }
}
internal bool AlwaysEmitTypeInformation
{
get
{
return _emitTypeInformation == EmitTypeInformation.Always;
}
}
public DateTimeFormat DateTimeFormat
{
@@ -527,7 +520,7 @@ namespace System.Runtime.Serialization.Json
{
}
internal DataContractJsonSerializerImpl(Type type,
internal DataContractJsonSerializerImpl(Type type,
XmlDictionaryString rootName,
IEnumerable<Type> knownTypes,
int maxItemsInObjectGraph,
@@ -576,8 +569,8 @@ namespace System.Runtime.Serialization.Json
if (this.knownDataContracts == null && this.knownTypeList != null)
{
// This assignment may be performed concurrently and thus is a race condition.
// It's safe, however, because at worse a new (and identical) dictionary of
// data contracts will be created and re-assigned to this field. Introduction
// It's safe, however, because at worse a new (and identical) dictionary of
// data contracts will be created and re-assigned to this field. Introduction
// of a lock here could lead to deadlocks.
this.knownDataContracts = XmlObjectSerializerContext.GetDataContractsForKnownTypes(this.knownTypeList);
}
@@ -705,7 +698,7 @@ namespace System.Runtime.Serialization.Json
public override void WriteObject(Stream stream, object graph)
{
CheckNull(stream, nameof(stream));
XmlDictionaryWriter jsonWriter = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, false); // ownsStream
XmlDictionaryWriter jsonWriter = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, false); // ownsStream
WriteObject(jsonWriter, graph);
jsonWriter.Flush();
}
@@ -804,7 +797,7 @@ namespace System.Runtime.Serialization.Json
internal static void WriteJsonNull(XmlWriterDelegator writer)
{
writer.WriteAttributeString(null, JsonGlobals.typeString, null, JsonGlobals.nullString); // prefix // namespace
writer.WriteAttributeString(null, JsonGlobals.typeString, null, JsonGlobals.nullString); // prefix // namespace
}
internal static void WriteJsonValue(JsonDataContract contract, XmlWriterDelegator writer, object graph, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
@@ -900,12 +893,12 @@ namespace System.Runtime.Serialization.Json
if (contract.CanContainReferences)
{
XmlObjectSerializerWriteContextComplexJson context = XmlObjectSerializerWriteContextComplexJson.CreateContext(this, contract);
context.OnHandleReference(writer, graph, true); // canContainReferences
context.OnHandleReference(writer, graph, true); // canContainReferences
context.SerializeWithoutXsiType(contract, writer, graph, declaredType.TypeHandle);
}
else
{
DataContractJsonSerializerImpl.WriteJsonValue(JsonDataContract.GetJsonDataContract(contract), writer, graph, null, declaredType.TypeHandle); // XmlObjectSerializerWriteContextComplexJson
DataContractJsonSerializerImpl.WriteJsonValue(JsonDataContract.GetJsonDataContract(contract), writer, graph, null, declaredType.TypeHandle); // XmlObjectSerializerWriteContextComplexJson
}
}
else
@@ -914,7 +907,7 @@ namespace System.Runtime.Serialization.Json
contract = DataContractJsonSerializerImpl.GetDataContract(contract, declaredType, graphType);
if (contract.CanContainReferences)
{
context.OnHandleReference(writer, graph, true); // canContainCyclicReference
context.OnHandleReference(writer, graph, true); // canContainCyclicReference
context.SerializeWithXsiTypeAtTopLevel(contract, writer, graph, declaredType.TypeHandle, graphType);
}
else

View File

@@ -213,23 +213,19 @@ namespace System.Runtime.Serialization.Json
int memberCount = (classContract.BaseContract == null) ? 0 :
WriteMembers(classContract.BaseContract, extensionDataLocal, derivedMostClassContract);
_ilg.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classContract.Members.Count);
int classMemberCount = classContract.Members.Count;
_ilg.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classMemberCount);
for (int i = 0; i < classContract.Members.Count; i++, memberCount++)
for (int i = 0; i < classMemberCount; i++, memberCount++)
{
DataMember member = classContract.Members[i];
Type memberType = member.MemberType;
LocalBuilder memberValue = null;
if (member.IsGetOnlyCollection)
{
_ilg.Load(_contextArg);
_ilg.Call(XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod);
}
else
{
_ilg.Load(_contextArg);
_ilg.Call(XmlFormatGeneratorStatics.ResetIsGetOnlyCollectionMethod);
}
_ilg.Load(_contextArg);
_ilg.Call(methodInfo: member.IsGetOnlyCollection ?
XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod :
XmlFormatGeneratorStatics.ResetIsGetOnlyCollectionMethod);
if (!member.EmitDefaultValue)
{
@@ -238,17 +234,17 @@ namespace System.Runtime.Serialization.Json
}
bool requiresNameAttribute = DataContractJsonSerializerImpl.CheckIfXmlNameRequiresMapping(classContract.MemberNames[i]);
if (requiresNameAttribute || !TryWritePrimitive(memberType, memberValue, member.MemberInfo, null /*arrayItemIndex*/, null /*nameLocal*/, i + _childElementIndex))
if (requiresNameAttribute || !TryWritePrimitive(memberType, memberValue, member.MemberInfo, arrayItemIndex: null, name: null, nameIndex: i + _childElementIndex))
{
// Note: DataContractSerializer has member-conflict logic here to deal with the schema export
// requirement that the same member can't be of two different types.
if (requiresNameAttribute)
{
_ilg.Call(null, JsonFormatGeneratorStatics.WriteJsonNameWithMappingMethod, _xmlWriterArg, _memberNamesArg, i + _childElementIndex);
_ilg.Call(thisObj: null, JsonFormatGeneratorStatics.WriteJsonNameWithMappingMethod, _xmlWriterArg, _memberNamesArg, i + _childElementIndex);
}
else
{
WriteStartElement(null /*nameLocal*/, i + _childElementIndex);
WriteStartElement(nameLocal: null, nameIndex: i + _childElementIndex);
}
if (memberValue == null)
memberValue = LoadMemberValue(member);
@@ -258,7 +254,7 @@ namespace System.Runtime.Serialization.Json
if (classContract.HasExtensionData)
{
_ilg.Call(_contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
_ilg.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
}
if (!member.EmitDefaultValue)
@@ -266,14 +262,14 @@ namespace System.Runtime.Serialization.Json
if (member.IsRequired)
{
_ilg.Else();
_ilg.Call(null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
_ilg.Call(thisObj: null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
}
_ilg.EndIf();
}
}
_typeIndex++;
_childElementIndex += classContract.Members.Count;
_childElementIndex += classMemberCount;
return memberCount;
}

View File

@@ -354,7 +354,7 @@ namespace System.Runtime.Serialization.Json
throw;
}
throw new Exception(SR.GenericCallbackException, e);
throw new InvalidOperationException(SR.GenericCallbackException, e);
}
}
base.Dispose(disposing);

View File

@@ -10,24 +10,6 @@ using System.Collections.Generic;
namespace System.Runtime.Serialization
{
using SchemaObjectDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, SchemaObjectInfo>;
internal class SchemaObjectInfo
{
internal XmlSchemaType type;
internal XmlSchemaElement element;
internal XmlSchema schema;
internal List<XmlSchemaType> knownTypes;
internal SchemaObjectInfo(XmlSchemaType type, XmlSchemaElement element, XmlSchema schema, List<XmlSchemaType> knownTypes)
{
this.type = type;
this.element = element;
this.schema = schema;
this.knownTypes = knownTypes;
}
}
internal static class SchemaHelper
{
@@ -62,36 +44,6 @@ namespace System.Runtime.Serialization
return null;
}
internal static XmlSchemaType GetSchemaType(SchemaObjectDictionary schemaInfo, XmlQualifiedName typeName)
{
SchemaObjectInfo schemaObjectInfo;
if (schemaInfo.TryGetValue(typeName, out schemaObjectInfo))
{
return schemaObjectInfo.type;
}
return null;
}
internal static XmlSchema GetSchemaWithType(SchemaObjectDictionary schemaInfo, XmlSchemaSet schemas, XmlQualifiedName typeName)
{
SchemaObjectInfo schemaObjectInfo;
if (schemaInfo.TryGetValue(typeName, out schemaObjectInfo))
{
if (schemaObjectInfo.schema != null)
return schemaObjectInfo.schema;
}
ICollection currentSchemas = schemas.Schemas();
string ns = typeName.Namespace;
foreach (XmlSchema schema in currentSchemas)
{
if (NamespacesEqual(ns, schema.TargetNamespace))
{
return schema;
}
}
return null;
}
internal static XmlSchemaElement GetSchemaElement(XmlSchemaSet schemas, XmlQualifiedName elementQName, out XmlSchema outSchema)
{
outSchema = null;
@@ -115,16 +67,6 @@ namespace System.Runtime.Serialization
return null;
}
internal static XmlSchemaElement GetSchemaElement(SchemaObjectDictionary schemaInfo, XmlQualifiedName elementName)
{
SchemaObjectInfo schemaObjectInfo;
if (schemaInfo.TryGetValue(elementName, out schemaObjectInfo))
{
return schemaObjectInfo.element;
}
return null;
}
internal static XmlSchema GetSchema(string ns, XmlSchemaSet schemas)
{
if (ns == null) { ns = String.Empty; }
@@ -183,51 +125,5 @@ namespace System.Runtime.Serialization
import.Namespace = ns;
schema.Includes.Add(import);
}
internal static XmlSchema GetSchemaWithGlobalElementDeclaration(XmlSchemaElement element, XmlSchemaSet schemas)
{
ICollection currentSchemas = schemas.Schemas();
foreach (XmlSchema schema in currentSchemas)
{
foreach (XmlSchemaObject schemaObject in schema.Items)
{
XmlSchemaElement schemaElement = schemaObject as XmlSchemaElement;
if (schemaElement == null)
continue;
if (schemaElement == element)
{
return schema;
}
}
}
return null;
}
internal static XmlQualifiedName GetGlobalElementDeclaration(XmlSchemaSet schemas, XmlQualifiedName typeQName, out bool isNullable)
{
ICollection currentSchemas = schemas.Schemas();
string ns = typeQName.Namespace;
if (ns == null)
ns = string.Empty;
isNullable = false;
foreach (XmlSchema schema in currentSchemas)
{
foreach (XmlSchemaObject schemaObject in schema.Items)
{
XmlSchemaElement schemaElement = schemaObject as XmlSchemaElement;
if (schemaElement == null)
continue;
if (schemaElement.SchemaTypeName.Equals(typeQName))
{
isNullable = schemaElement.IsNillable;
return new XmlQualifiedName(schemaElement.Name, schema.TargetNamespace);
}
}
}
return null;
}
}
}

View File

@@ -271,26 +271,25 @@ namespace System.Runtime.Serialization
_ilg.LoadMember(XmlFormatGeneratorStatics.NamespaceProperty);
}
else
{
_ilg.LoadArrayElement(_contractNamespacesLocal, _typeIndex - 1);
}
_ilg.Store(namespaceLocal);
_ilg.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classContract.Members.Count);
int classMemberCount = classContract.Members.Count;
_ilg.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classMemberCount);
for (int i = 0; i < classContract.Members.Count; i++, memberCount++)
for (int i = 0; i < classMemberCount; i++, memberCount++)
{
DataMember member = classContract.Members[i];
Type memberType = member.MemberType;
LocalBuilder memberValue = null;
if (member.IsGetOnlyCollection)
{
_ilg.Load(_contextArg);
_ilg.Call(XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod);
}
else
{
_ilg.Load(_contextArg);
_ilg.Call(XmlFormatGeneratorStatics.ResetIsGetOnlyCollectionMethod);
}
_ilg.Load(_contextArg);
_ilg.Call(methodInfo: member.IsGetOnlyCollection ?
XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod :
XmlFormatGeneratorStatics.ResetIsGetOnlyCollectionMethod);
if (!member.EmitDefaultValue)
{
@@ -298,14 +297,14 @@ namespace System.Runtime.Serialization
_ilg.IfNotDefaultValue(memberValue);
}
bool writeXsiType = CheckIfMemberHasConflict(member, classContract, derivedMostClassContract);
if (writeXsiType || !TryWritePrimitive(memberType, memberValue, member.MemberInfo, null /*arrayItemIndex*/, namespaceLocal, null /*nameLocal*/, i + _childElementIndex))
if (writeXsiType || !TryWritePrimitive(memberType, memberValue, member.MemberInfo, arrayItemIndex: null, ns: namespaceLocal, name: null, nameIndex: i + _childElementIndex))
{
WriteStartElement(memberType, classContract.Namespace, namespaceLocal, null /*nameLocal*/, i + _childElementIndex);
WriteStartElement(memberType, classContract.Namespace, namespaceLocal, nameLocal: null, nameIndex: i + _childElementIndex);
if (classContract.ChildElementNamespaces[i + _childElementIndex] != null)
{
_ilg.Load(_xmlWriterArg);
_ilg.LoadArrayElement(_childElementNamespacesLocal, i + _childElementIndex);
_ilg.Call(XmlFormatGeneratorStatics.WriteNamespaceDeclMethod);
_ilg.Call(methodInfo: XmlFormatGeneratorStatics.WriteNamespaceDeclMethod);
}
if (memberValue == null)
memberValue = LoadMemberValue(member);
@@ -315,23 +314,22 @@ namespace System.Runtime.Serialization
if (classContract.HasExtensionData)
{
_ilg.Call(_contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
_ilg.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
}
if (!member.EmitDefaultValue)
{
if (member.IsRequired)
{
_ilg.Else();
_ilg.Call(null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
_ilg.Call(thisObj: null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
}
_ilg.EndIf();
}
}
_typeIndex++;
_childElementIndex += classContract.Members.Count;
_childElementIndex += classMemberCount;
return memberCount;
}

View File

@@ -4,7 +4,7 @@
namespace System.Xml
{
internal struct BytesWithOffset
internal readonly struct BytesWithOffset
{
private readonly byte[] _bytes;
private readonly int _offset;

View File

@@ -824,13 +824,6 @@ namespace System.Xml
return _nsMgr.LookupPrefix(ns);
}
internal string LookupNamespace(string prefix)
{
if (prefix == null)
return null;
return _nsMgr.LookupNamespace(prefix);
}
private string GetQualifiedNamePrefix(string namespaceUri, XmlDictionaryString xNs)
{
string prefix = _nsMgr.LookupPrefix(namespaceUri);
@@ -921,7 +914,7 @@ namespace System.Xml
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidDeclaration)));
// The only thing the text can legitimately contain is version, encoding, and standalone.
// We only support version 1.0, we can only write whatever encoding we were supplied,
// We only support version 1.0, we can only write whatever encoding we were supplied,
// and we don't support DTDs, so whatever values are supplied in the text argument are irrelevant.
_writer.WriteDeclaration();
}
@@ -952,18 +945,6 @@ namespace System.Xml
_documentState = DocumentState.End;
}
protected int NamespaceBoundary
{
get
{
return _nsMgr.NamespaceBoundary;
}
set
{
_nsMgr.NamespaceBoundary = value;
}
}
public override void WriteEntityRef(string name)
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.XmlMethodNotSupported, "WriteEntityRef")));
@@ -1855,7 +1836,6 @@ namespace System.Xml
private int _attributeCount;
private XmlSpace _space;
private string _lang;
private int _namespaceBoundary;
private int _nsTop;
private Namespace _defaultNamespace;
@@ -1898,26 +1878,6 @@ namespace System.Xml
_space = XmlSpace.None;
_lang = null;
_lastNameSpace = null;
_namespaceBoundary = 0;
}
public int NamespaceBoundary
{
get
{
return _namespaceBoundary;
}
set
{
int i;
for (i = 0; i < _nsCount; i++)
if (_namespaces[i].Depth >= value)
break;
_nsTop = i;
_namespaceBoundary = value;
_lastNameSpace = null;
}
}
public void Close()

View File

@@ -676,13 +676,6 @@ namespace System.Xml
return new string(chars, 0, charCount);
}
public string GetEscapedString(int offset, int length, XmlNameTable nameTable)
{
char[] chars = GetCharBuffer(length);
int charCount = GetEscapedChars(offset, length, chars);
return nameTable.Add(chars, 0, charCount);
}
private int GetLessThanCharEntity(int offset, int length)
{
byte[] buffer = _buffer;
@@ -1347,4 +1340,4 @@ namespace System.Xml
return list.ToArray();
}
}
}
}

View File

@@ -132,11 +132,6 @@ namespace System.Xml
ThrowXmlException(reader, SR.XmlMaxBytesPerReadExceeded, maxBytesPerRead.ToString(NumberFormatInfo.CurrentInfo));
}
public static void ThrowMaxNameTableCharCountExceeded(XmlDictionaryReader reader, int maxNameTableCharCount)
{
ThrowXmlException(reader, SR.XmlMaxNameTableCharCountExceeded, maxNameTableCharCount.ToString(NumberFormatInfo.CurrentInfo));
}
public static void ThrowMaxDepthExceeded(XmlDictionaryReader reader, int maxDepth)
{
ThrowXmlException(reader, SR.XmlMaxDepthExceeded, maxDepth.ToString());

View File

@@ -33,19 +33,6 @@ namespace System.Xml
_encoding = encoding;
}
// Getting/Setting the Stream exists for fragmenting
public Stream Stream
{
get
{
return _stream;
}
set
{
_stream = value;
}
}
// StreamBuffer/BufferOffset exists only for the BinaryWriter to fix up nodes
public byte[] StreamBuffer
{
@@ -480,4 +467,4 @@ namespace System.Xml
}
}
}
}
}

View File

@@ -115,14 +115,6 @@ namespace System.Xml
_inAttribute = false;
}
public Encoding Encoding
{
get
{
return _encoding;
}
}
private byte[] GetCharEntityBuffer()
{
if (_entityChars == null)
@@ -823,4 +815,4 @@ namespace System.Xml
WriteText(localName);
}
}
}
}