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

@@ -2,7 +2,8 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.3.0</AssemblyVersion>
<AssemblyVersion>4.1.4.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsNETCoreAppRef>false</IsNETCoreAppRef>
<IsUAP>true</IsUAP>

View File

@@ -0,0 +1,8 @@
<linker>
<assembly fullname="System.Private.DataContractSerialization">
<type fullname="System.Runtime.Serialization.DataContractSerializer">
<!-- called through reflection by tests -->
<method name="set_Option" />
</type>
</assembly>
</linker>

View File

@@ -1084,4 +1084,46 @@
<data name="ParseJsonNumberReturnInvalidNumber" xml:space="preserve">
<value>JsonObjectDataContract.ParseJsonNumber shouldn't return a TypeCode that we're not expecting.</value>
</data>
<data name="CouldNotReadSerializationSchema" xml:space="preserve">
<value>An internal error has occurred. Could not load serialization schema. Consider providing schema with namespace '{0}'.</value>
</data>
<data name="MissingSchemaType" xml:space="preserve">
<value>Schema type '{0}' returned by CLR type '{1}' is not found in the XmlSchemaSet.</value>
</data>
<data name="InvalidReturnSchemaOnGetSchemaMethod" xml:space="preserve">
<value>Method '{0}.GetSchema()' must return a schema with a valid Id.</value>
</data>
<data name="PlatformNotSupported_MtomEncoding" xml:space="preserve">
<value>The Message Transmission Optimization Mechanism (MTOM) message encoding is not supported on this platform.</value>
</data>
<data name="PlatformNotSupported_NetDataContractSerializer" xml:space="preserve">
<value>System.Runtime.Serialization.NetDataContractSerializer is not supported on this platform.</value>
</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>
<data name="PlatformNotSupported_SchemaImporter" xml:space="preserve">
<value>The implementation of the function requires System.Runtime.Serialization.SchemaImporter which is not supported on this platform.</value>
</data>
<data name="PlatformNotSupported_Canonicalization" xml:space="preserve">
<value>The canonicalization process is not supported on this platform.</value>
</data>
<data name="FactoryTypeNotISerializable" xml:space="preserve">
<value>Factory type '{0}' for ISerializable type '{1}' must also be ISerializable.</value>
</data>
<data name="XmlCanonicalizationStarted" xml:space="preserve">
<value>Canonicalization already started.</value>
</data>
<data name="XmlCanonicalizationNotStarted" xml:space="preserve">
<value>Canonicalization not started.</value>
</data>
<data name="CombinedPrefixNSLength" xml:space="preserve">
<value>The combined length of the prefix and namespace must not be greater than {0}.</value>
</data>
<data name="InvalidInclusivePrefixListCollection" xml:space="preserve">
<value>The inclusive namespace prefix collection cannot contain null as one of the items.</value>
</data>
<data name="FailedToCreateMethodDelegate" xml:space="preserve">
<value>Failed to create Delegate for method '{0}' of type '{1}'.</value>
</data>
</root>

View File

@@ -8,8 +8,29 @@
<TypeParameter Name="type" DataContractSerializer="Public"/>
<TypeEnumerableParameter Name="knownTypes" DataContractSerializer="Public"/>
</Method>
<Property Name="Option" Dynamic="Required" />
</Type>
<Type Name="KeyValuePairAdapter`2" Dynamic="Required All" />
<!-- Reflection-based serialization requires the entries below. -->
<Type Name="CollectionDataContract">
<Type Name="CollectionDataContractCriticalHelper">
<Method Name="BuildCreateGenericDictionaryEnumerator{K, V}" Dynamic="Required" />
<Method Name="BuildIncrementCollectionCountDelegate{T}" Dynamic="Required" />
</Type>
</Type>
<Type Name="DateTimeOffsetAdapter" Dynamic="Required All" />
<Type Name="FastInvokerBuilder" Dynamic="Required All" />
<Type Name="ReflectionReader">
<Method Name="GetCollectionSetItemDelegate{T}" Dynamic="Required" />
<Method Name="ObjectToKeyValuePairGetKey{K, V}" Dynamic="Required" />
<Method Name="ObjectToKeyValuePairGetValue{K, V}" Dynamic="Required" />
</Type>
<Type Name="XmlObjectSerializerReadContext">
<Method Name="TrimArraySize{T}" Dynamic="Required" />
</Type>
<Type Name="XmlObjectSerializerWriteContext">
<Method Name="GetDefaultValue{T}" Dynamic="Required" />
</Type>
</Namespace>
<Namespace Name="System.Runtime.Serialization.Json">
<Type Name="DataContractJsonSerializer">
@@ -20,5 +41,9 @@
</Type>
</Namespace>
</Assembly>
<Namespace Name="System.Collections">
<Type Name="IEnumerable" Dynamic="Required All" />
<Type Name="IEnumerator" Dynamic="Required All" />
</Namespace>
</Library>
</Directives>

View File

@@ -11,7 +11,7 @@
<DebugSymbols>true</DebugSymbols>
<PlatformTarget>AnyCPU</PlatformTarget>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)' == 'uapaot'">$(DefineConstants);uapaot</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)' == 'uapaot'">$(DefineConstants);uapaot</DefineConstants>
<!-- We do not want to block reflection for this assembly -->
<BlockReflectionAttribute Condition="'$(TargetGroup)'=='uapaot'">false</BlockReflectionAttribute>
</PropertyGroup>
@@ -53,7 +53,7 @@
<Compile Include="$(RuntimeSerializationSources)\Globals.cs" />
<Compile Include="$(RuntimeSerializationSources)\GenericParameterDataContract.cs" />
<Compile Include="$(RuntimeSerializationSources)\HybridObjectCache.cs" />
<Compile Include="$(RuntimeSerializationSources)\InvalidDataContract.cs" Condition="'$(TargetGroup)' == 'uapaot'" />
<Compile Include="$(RuntimeSerializationSources)\InvalidDataContract.cs" Condition="'$(TargetGroup)' == 'uapaot'" />
<Compile Include="$(RuntimeSerializationSources)\ObjectToIdCache.cs" />
<Compile Include="$(RuntimeSerializationSources)\ObjectReferenceStack.cs" />
<Compile Include="$(RuntimeSerializationSources)\PrimitiveDataContract.cs" />
@@ -160,13 +160,15 @@
<Compile Include="System\Runtime\Serialization\SerializationOption.cs" />
<Compile Include="System\Runtime\Serialization\XPathQueryGenerator.cs" />
<Compile Include="System\Runtime\Serialization\XsdDataContractExporter.cs" />
<Compile Include="System\Runtime\Serialization\SurrogateDataContract.cs" />
<Compile Include="System\Xml\IFragmentCapableXmlDictionaryWriter.cs" />
<Compile Include="System\Xml\XmlCanonicalWriter.cs" />
<Compile Include="System\Xml\XmlSigningNodeWriter.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='uapaot'">
<EmbeddedResource Include="$(MsBuildThisFileDirectory)Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.CodeDom" />
<Reference Include="System.Collections" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.Collections.NonGeneric" />

View File

@@ -179,7 +179,14 @@ namespace System.Runtime.Serialization
// a generic extension for CreateDelegate
public static T CreateDelegate<T>(this MethodInfo method) where T : class
{
return method.CreateDelegate(typeof(T)) as T;
try
{
return method.CreateDelegate(typeof(T)) as T;
}
catch(Exception e)
{
throw new InvalidOperationException(SR.Format(SR.FailedToCreateMethodDelegate, method.Name, method.DeclaringType.FullName), e);
}
}
}
}

View File

@@ -24,6 +24,7 @@ namespace System.Runtime.Serialization
DictionaryGlobals.RefLocalName,
DictionaryGlobals.ClrTypeLocalName,
DictionaryGlobals.ClrAssemblyLocalName,
DictionaryGlobals.ISerializableFactoryTypeLocalName
};
s_schemaInstanceLocalNames = new XmlDictionaryString[]

View File

@@ -329,7 +329,7 @@ namespace System.Runtime.Serialization
{
ClassDataContract cloned = cdc.Clone();
cloned.UpdateNamespaceAndMembers(type, ns, memberNames);
return cloned;
return cloned;
}
}
@@ -459,8 +459,7 @@ namespace System.Runtime.Serialization
//
string typeFullName = GetGeneralTypeName(type);
return s_knownSerializableTypeInfos.ContainsKey(typeFullName)
|| Globals.TypeOfException.IsAssignableFrom(type);
return s_knownSerializableTypeInfos.ContainsKey(typeFullName);
}
internal static bool IsNonSerializedMember(Type type, string memberName)
@@ -776,7 +775,23 @@ namespace System.Runtime.Serialization
this.IsValueType = type.IsValueType;
if (baseType != null && baseType != Globals.TypeOfObject && baseType != Globals.TypeOfValueType && baseType != Globals.TypeOfUri)
{
// dotnet/corefx#19629: a DataContract created at runtime does not work with the base DataContract
// pre-generated by SG. It's because the runtime DataContract requires full information of a base DataContract
// while a pre-generated DataContract is incomplete.
//
// At this point in code, we're in the midlle of creating a new DataContract at runtime, so we need to make
// sure that we create our own base type DataContract when the base type could potentially have SG generated
// DataContract.
//
// We wanted to enable the fix for the issue described above only when SG generated DataContracts are available.
// Currently we don't have a good way of detecting usage of SG (either globally or per data contract).
// But since SG is currently only used by .NET Native, so we used the "#if uapaot" to target the fix for .Net
// Native only.
#if uapaot
DataContract baseContract = DataContract.GetDataContractCreatedAtRuntime(baseType);
#else
DataContract baseContract = DataContract.GetDataContract(baseType);
#endif
if (baseContract is CollectionDataContract)
this.BaseContract = ((CollectionDataContract)baseContract).SharedTypeContract as ClassDataContract;
else
@@ -1015,7 +1030,7 @@ namespace System.Runtime.Serialization
DataMember memberContract = new DataMember(member);
if (property != null)
{
MethodInfo getMethod = property.GetMethod;
MethodInfo getMethod = property.GetGetMethod();
if (getMethod == null || IsMethodOverriding(getMethod) || getMethod.GetParameters().Length > 0)
continue;
@@ -1044,7 +1059,7 @@ namespace System.Runtime.Serialization
// Previously System.SerializableAttribute was not available in NetCore, so we had
// a list of known [Serializable] types for type in the framework. Although now SerializableAttribute
// is available in NetCore, some framework types still do not have [Serializable]
// is available in NetCore, some framework types still do not have [Serializable]
// yet, e.g. ReadOnlyDictionary<TKey, TValue>. So, we still need to maintain the known serializable
// type list.
if (IsKnownSerializableType(type))
@@ -1118,6 +1133,7 @@ namespace System.Runtime.Serialization
while (currContract != null)
{
baseTypeIndex++;
foreach (DataMember member in currContract.Members)
{
membersInHierarchy.Add(new Member(member, currContract.StableName.Namespace, baseTypeIndex));
@@ -1172,7 +1188,7 @@ namespace System.Runtime.Serialization
/// <SecurityNote>
/// RequiresReview - marked SRR because callers may need to depend on isNonAttributedType for a security decision
/// isNonAttributedType must be calculated correctly
/// SetIsNonAttributedType should not be called before GetStableNameAndSetHasDataContract since it
/// SetIsNonAttributedType should not be called before GetStableNameAndSetHasDataContract since it
/// is dependent on the correct calculation of hasDataContract
/// Safe - does not let caller influence isNonAttributedType calculation; no harm in leaking value
/// </SecurityNote>

View File

@@ -288,6 +288,12 @@ namespace System.Runtime.Serialization
}
}
internal bool IsItemTypeNullable
{
get { return _helper.IsItemTypeNullable; }
set { _helper.IsItemTypeNullable = value; }
}
internal bool IsConstructorCheckRequired
{
get
@@ -432,7 +438,12 @@ namespace System.Runtime.Serialization
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.GetOnlyCollectionMustHaveAddMethod, GetClrTypeFullName(UnderlyingType))));
}
Debug.Assert(AddMethod != null || Kind == CollectionKind.Array, "Add method cannot be null if the collection is being used as a get-only property");
if (Kind != CollectionKind.Array && AddMethod == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.GetOnlyCollectionMustHaveAddMethod, GetClrTypeFullName(UnderlyingType))));
}
XmlFormatGetOnlyCollectionReaderDelegate tempDelegate = new XmlFormatReaderGenerator().GenerateGetOnlyCollectionReader(this);
Interlocked.MemoryBarrier();
_helper.XmlFormatGetOnlyCollectionReaderDelegate = tempDelegate;
@@ -464,6 +475,7 @@ namespace System.Runtime.Serialization
private static Type[] s_knownInterfaces;
private Type _itemType;
private bool _isItemTypeNullable;
private CollectionKind _kind;
private readonly MethodInfo _getEnumeratorMethod, _addMethod;
private readonly ConstructorInfo _constructor;
@@ -512,6 +524,7 @@ namespace System.Runtime.Serialization
if (itemType != null)
{
_itemType = itemType;
_isItemTypeNullable = DataContract.IsTypeNullable(itemType);
bool isDictionary = (kind == CollectionKind.Dictionary || kind == CollectionKind.GenericDictionary);
string itemName = null, keyName = null, valueName = null;
@@ -697,6 +710,12 @@ namespace System.Runtime.Serialization
set { _childElementNamespace = value; }
}
internal bool IsItemTypeNullable
{
get { return _isItemTypeNullable; }
set { _isItemTypeNullable = value; }
}
internal MethodInfo GetEnumeratorMethod => _getEnumeratorMethod;
internal MethodInfo AddMethod => _addMethod;

View File

@@ -1 +1 @@
cabcd377a64462c95dfe88419af95a281abe71a6
d1903e135a02d45d5e9f0e7ae1c8d8105ccaaed0

View File

@@ -30,7 +30,7 @@ namespace System.Runtime.Serialization
public DateTime UtcDateTime
{
get { return _utcDateTime; }
set { _utcDateTime = DateTime.SpecifyKind(value, DateTimeKind.Utc); }
set { _utcDateTime = value; }
}
[DataMember(Name = "OffsetMinutes", IsRequired = true)]

View File

@@ -346,6 +346,31 @@ namespace System.Runtime.Serialization
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidEnumValueOnRead, value.Substring(index, count), DataContract.GetClrTypeFullName(UnderlyingType))));
}
internal string GetStringFromEnumValue(long value)
{
if (IsULong)
{
return XmlConvert.ToString((ulong)value);
}
else
{
return XmlConvert.ToString(value);
}
}
internal long GetEnumValueFromString(string value)
{
if (IsULong)
{
return (long)XmlConverter.ToUInt64(value);
}
else
{
return XmlConverter.ToInt64(value);
}
}
public override void WriteXmlValue(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context)
{
WriteEnumValue(xmlWriter, obj);

View File

@@ -78,17 +78,6 @@ namespace System.Runtime.Serialization
}
}
private static Type s_typeOfException;
internal static Type TypeOfException
{
get
{
if (s_typeOfException == null)
s_typeOfException = typeof(Exception);
return s_typeOfException;
}
}
private static Type s_typeOfString;
internal static Type TypeOfString
{
@@ -243,6 +232,17 @@ namespace System.Runtime.Serialization
}
}
private static Type s_typeOfIObjectReference;
internal static Type TypeOfIObjectReference
{
get
{
if (s_typeOfIObjectReference == null)
s_typeOfIObjectReference = typeof(IObjectReference);
return s_typeOfIObjectReference;
}
}
private static Type s_typeOfXmlFormatClassWriterDelegate;
internal static Type TypeOfXmlFormatClassWriterDelegate
{
@@ -477,11 +477,25 @@ namespace System.Runtime.Serialization
}
}
private static Type s_typeOfXmlSchemaType;
internal static Type TypeOfXmlSchemaType
{
get
{
if (s_typeOfXmlSchemaType == null)
{
s_typeOfXmlSchemaType = typeof(XmlSchemaType);
}
return s_typeOfXmlSchemaType;
}
}
private static Type s_typeOfIExtensibleDataObject;
internal static Type TypeOfIExtensibleDataObject => s_typeOfIExtensibleDataObject ?? (s_typeOfIExtensibleDataObject = typeof (IExtensibleDataObject));
internal static Type TypeOfIExtensibleDataObject => s_typeOfIExtensibleDataObject ?? (s_typeOfIExtensibleDataObject = typeof(IExtensibleDataObject));
private static Type s_typeOfExtensionDataObject;
internal static Type TypeOfExtensionDataObject => s_typeOfExtensionDataObject ?? (s_typeOfExtensionDataObject = typeof (ExtensionDataObject));
internal static Type TypeOfExtensionDataObject => s_typeOfExtensionDataObject ?? (s_typeOfExtensionDataObject = typeof(ExtensionDataObject));
private static Type s_typeOfISerializableDataNode;
internal static Type TypeOfISerializableDataNode
@@ -517,7 +531,7 @@ namespace System.Runtime.Serialization
}
private static Type s_typeOfXmlDataNode;
internal static Type TypeOfXmlDataNode => s_typeOfXmlDataNode ?? (s_typeOfXmlDataNode = typeof (XmlDataNode));
internal static Type TypeOfXmlDataNode => s_typeOfXmlDataNode ?? (s_typeOfXmlDataNode = typeof(XmlDataNode));
#if uapaot
private static Type s_typeOfSafeSerializationManager;
@@ -778,38 +792,17 @@ namespace System.Runtime.Serialization
}
}
private static bool s_shouldGetDBNullType = true;
private static Type s_typeOfDBNull;
internal static Type TypeOfDBNull
{
get
get
{
if (s_typeOfDBNull == null && s_shouldGetDBNullType)
{
s_typeOfDBNull = Type.GetType("System.DBNull, System.Data.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", false);
s_shouldGetDBNullType = false;
}
if (s_typeOfDBNull == null)
s_typeOfDBNull = typeof(DBNull);
return s_typeOfDBNull;
}
}
private static object s_valueOfDBNull;
internal static object ValueOfDBNull
{
get
{
if (s_valueOfDBNull == null && TypeOfDBNull != null)
{
var fieldInfo = TypeOfDBNull.GetField("Value");
if (fieldInfo != null)
s_valueOfDBNull = fieldInfo.GetValue(null);
}
return s_valueOfDBNull;
}
}
private static Uri s_dataContractXsdBaseNamespaceUri;
internal static Uri DataContractXsdBaseNamespaceUri
{
@@ -895,11 +888,6 @@ namespace System.Runtime.Serialization
return Globals.s_deserializeFunc(json);
}
internal static bool IsDBNullValue(object o)
{
return o != null && ValueOfDBNull != null && ValueOfDBNull.Equals(o);
}
public const bool DefaultIsRequired = false;
public const bool DefaultEmitDefaultValue = true;
public const int DefaultOrder = 0;
@@ -999,5 +987,48 @@ namespace System.Runtime.Serialization
public const string SafeSerializationManagerName = "SafeSerializationManager";
public const string SafeSerializationManagerNamespace = "http://schemas.datacontract.org/2004/07/System.Runtime.Serialization";
public const string ISerializableFactoryTypeLocalName = "FactoryType";
public const string SerializationSchema = @"<?xml version='1.0' encoding='utf-8'?>
<xs:schema elementFormDefault='qualified' attributeFormDefault='qualified' xmlns:tns='http://schemas.microsoft.com/2003/10/Serialization/' targetNamespace='http://schemas.microsoft.com/2003/10/Serialization/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='anyType' nillable='true' type='xs:anyType' />
<xs:element name='anyURI' nillable='true' type='xs:anyURI' />
<xs:element name='base64Binary' nillable='true' type='xs:base64Binary' />
<xs:element name='boolean' nillable='true' type='xs:boolean' />
<xs:element name='byte' nillable='true' type='xs:byte' />
<xs:element name='dateTime' nillable='true' type='xs:dateTime' />
<xs:element name='decimal' nillable='true' type='xs:decimal' />
<xs:element name='double' nillable='true' type='xs:double' />
<xs:element name='float' nillable='true' type='xs:float' />
<xs:element name='int' nillable='true' type='xs:int' />
<xs:element name='long' nillable='true' type='xs:long' />
<xs:element name='QName' nillable='true' type='xs:QName' />
<xs:element name='short' nillable='true' type='xs:short' />
<xs:element name='string' nillable='true' type='xs:string' />
<xs:element name='unsignedByte' nillable='true' type='xs:unsignedByte' />
<xs:element name='unsignedInt' nillable='true' type='xs:unsignedInt' />
<xs:element name='unsignedLong' nillable='true' type='xs:unsignedLong' />
<xs:element name='unsignedShort' nillable='true' type='xs:unsignedShort' />
<xs:element name='char' nillable='true' type='tns:char' />
<xs:simpleType name='char'>
<xs:restriction base='xs:int'/>
</xs:simpleType>
<xs:element name='duration' nillable='true' type='tns:duration' />
<xs:simpleType name='duration'>
<xs:restriction base='xs:duration'>
<xs:pattern value='\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?' />
<xs:minInclusive value='-P10675199DT2H48M5.4775808S' />
<xs:maxInclusive value='P10675199DT2H48M5.4775807S' />
</xs:restriction>
</xs:simpleType>
<xs:element name='guid' nillable='true' type='tns:guid' />
<xs:simpleType name='guid'>
<xs:restriction base='xs:string'>
<xs:pattern value='[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}' />
</xs:restriction>
</xs:simpleType>
<xs:attribute name='FactoryType' type='xs:QName' />
<xs:attribute name='Id' type='xs:ID' />
<xs:attribute name='Ref' type='xs:IDREF' />
</xs:schema>
";
}
}

View File

@@ -256,8 +256,24 @@ namespace System.Runtime.Serialization.Json
}
}
bool HasFactoryMethod(ClassDataContract classContract)
{
return Globals.TypeOfIObjectReference.IsAssignableFrom(classContract.UnderlyingType);
}
private bool InvokeFactoryMethod(ClassDataContract classContract)
{
if (HasFactoryMethod(classContract))
{
_ilg.Load(_contextArg);
_ilg.LoadAddress(_objectLocal);
_ilg.ConvertAddress(_objectLocal.LocalType, Globals.TypeOfIObjectReference);
_ilg.Load(Globals.NewObjectId);
_ilg.Call(XmlFormatGeneratorStatics.GetRealObjectMethod);
_ilg.ConvertValue(Globals.TypeOfObject, _ilg.CurrentMethod.ReturnType);
return true;
}
return false;
}

View File

@@ -180,7 +180,7 @@ namespace System.Runtime.Serialization.Json
// Fetching the UtcOffset is expensive so we need to avoid it if possible. We can do a fast
// bounds check to decide if the more expensive bounds check is needed. The result from
// TimeZoneInfo.Local.GetUtcOffset(value) is bounded to +/- 24 hours. If
// (DateTime.MinValue + 24 hours) < value < (DateTime.MaxValue <EFBFBD> 24 hours), then we don't need
// (DateTime.MinValue + 24 hours) < value < (DateTime.MaxValue - 24 hours), then we don't need
// to check using the real UtcOffset as it doesn't matter what the offset is, it can't cause
// an overflow/underflow condition.

View File

@@ -62,6 +62,15 @@ namespace System.Runtime.Serialization.Json
int reflectedMemberCount = ReflectionGetMembers(classContract, members);
int memberIndex = -1;
ExtensionDataObject extensionData = null;
if (classContract.HasExtensionData)
{
extensionData = new ExtensionDataObject();
((IExtensibleDataObject)obj).ExtensionData = extensionData;
}
while (true)
{
if (!XmlObjectSerializerReadContext.MoveToNextElement(xmlReader))
@@ -69,7 +78,7 @@ namespace System.Runtime.Serialization.Json
return;
}
memberIndex = jsonContext.GetJsonMemberIndex(xmlReader, memberNames, memberIndex, extensionData: null);
memberIndex = jsonContext.GetJsonMemberIndex(xmlReader, memberNames, memberIndex, extensionData);
// GetMemberIndex returns memberNames.Length if member not found
if (memberIndex < members.Length)
{

View File

@@ -243,6 +243,11 @@ namespace System.Runtime.Serialization.Json
ReflectionWriteValue(xmlWriter, context, memberType, memberValue, false/*writeXsiType*/, primitiveContractForParamType: null);
ReflectionWriteEndElement(xmlWriter);
}
if(classContract.HasExtensionData)
{
context.WriteExtensionData(xmlWriter, ((IExtensibleDataObject)obj).ExtensionData, memberCount);
}
}
}

View File

@@ -1689,6 +1689,11 @@ namespace System.Runtime.Serialization.Json
return sb.ToString();
}
protected override XmlSigningNodeWriter CreateSigningNodeWriter()
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.JsonMethodNotSupported, "CreateSigningNodeWriter")));
}
private static class CharType
{
public const byte FirstName = 0x01;

View File

@@ -1,13 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//------------------------------------------------------------
namespace System.Runtime.Serialization
{
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class OnDeserializedAttribute : Attribute
{
}
}

View File

@@ -1,13 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//------------------------------------------------------------
namespace System.Runtime.Serialization
{
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class OnDeserializingAttribute : Attribute
{
}
}

Some files were not shown because too many files have changed in this diff Show More